|
|
||||||
|
#1
|
|
|
|
|
Hi
We have a list of file paths and short file names in our database. We need to loop through them all, picking up the long file name from the file itself and check that the long file name does not include a "~" character. I have the short file name and path in a variable (eg "c:\data\123442~1.doc") how can I get the long file name from this data. Any advice would be much appreciated. Thanks B |
|
|
|
#2
|
|
|
|
|
Good ol' Dir( ) from vb6 will do what you want.
Dim filename As String = "C:\somelo~1.txt" Console.WriteLine(Dir(filename)) Console.ReadLine() Exit Sub ^ Outputs 'somelongfilename.txt' to the console. That's the quickest way I can think of. I looked at the System.IO.File and although it accepts both long names and the 8dot3 file names, I couldn't find a way to switch between the two. John |
|
#3
|
|
|
|
|
Thanks John thats perfect!!
B "jayeldee" <jayeldee> wrote in message news:1630 [..] |
|
#4
|
|
|
|
|
I use the below for getting a short path from a long path so there is
probably an API function for getting a longpath from a short paty. Hope this helps. Protected Declare Ansi Function GetShortPathName Lib "kernel32.dll" Alias "GetShortPathNameA" (ByVal lpszLongPath As String, ByVal lpszShortPath As StringBuilder, ByVal cchBuffer As Integer) As Integer Protected Function GetShortPath(ByVal file As String) As String Dim buffer As StringBuilder = New StringBuilder(file.Length + 1) Dim ret As Integer = GetShortPathName(file, buffer, buffer.Capacity) If ret = 0 Then ' Error Return "" Else ' Success Return buffer.ToString() End If End Function |
|
#5
|
|
|
|
|
There sure is!
http://www.pinvoke.net/default.aspx/...etLongPathName ^ has the C# syntax for the call, which shouldnt' be that hard to convert with the code Dennis posted. John (also in Houston!) |
|
|
| Similar Threads | |
| Utility to save file list with long file names Does anyone know of a handy utility which can save the list of folders and files in a directory with their long file names? The DIR command only outputs 8.3... |
|
| long file names in Mac OS X in list view This may well be an issue/feature on all versions of Mac, but how do you get the full file name for files with long file names to display properly in finder when looking at... |
|
| need to copy a long list of file names I have a long list of file names (240 from a search) that I need to put into Excel. Copy won't do it. How now brown cow??? |
|
| Long file names suddenly converted to short file names I am running Windows XP SP2 and am connecting to a Windows 2003 Server. This morning I opened up a folder on the server and noticed hat all the files in it had been renamed... |
|
| modifying long list of file names What language do you think would be most suitable for the following task: I have a long list of, say, mp3 files, and I like their file names formatted in a certain way. So I... |
|
|
All times are GMT. The time now is 02:38 AM. | Privacy Policy
|