![]() |
|
[.NET] [VB.NET] Help with changing file extension - Printable Version +- Hack Forums (https://hackforums.net) +-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444) +--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151) +---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118) +---- Thread: [.NET] [VB.NET] Help with changing file extension (/showthread.php?tid=5670871) |
[VB.NET] Help with changing file extension - Dushidude - Jul 16, 2017 I need help to make a code which gets the file extension from a specific path, and then changes it to a new file extension. For example from .txt to .pdf. The file extension can be random, so the code has to find out what the extension is. * - Washi - Jul 16, 2017 Have a look at the Path.ChangeExtension(String, String) and File.Move(String, String) methods. Combined they do exactly what you need. * - zeroexp - Jul 16, 2017 Here's all you have to know, although your threads are very fucking sketchy so I won't give you any code. Path.GetExtension Path.GetFileNameWithoutExtension Path.GetDirectoryName System.IO.File.Move System.IO.File.Delete Alternatively you can use ChangeExtension as said by Washi but I never tried it before so constructing the path based on the first 3 methods is what I recommend. * - Barret - Jul 16, 2017 Do not spoon feed this one, he's up to no good lads. (check his threads, you'll see what i mean) * - darkdoctor - Jul 16, 2017 In c# you can simply rename the file . string fileName = Path.GetFileName(path); string ext = Path.GetExtension(path); string newFileName = fileName + Reverse(ext); File.move(path,newFileName); * - ForceJew - Jul 16, 2017 Should be closed and not banned His thread were literally: How to spread How to encrypt files How to changeextension. For sure not ransomware |