Retrieving info on files with a long name using .NET

G

Guest

I had previously written a program to set the attributes of all files in a
folder. The program uses the Windows API functions FindFirstFile and
FindFindNextFile to process the files in a specified folder and its
sub-folders. By specify the prefix “\\?\UNC\†or “\\?\†files or folders
with names longer than 260 characters are processed. I have now written a
VB.NET 2003 equivalent using.NET Framework version 1.1. The program uses the
Directory class methods GetDirectories and GetFiles, and the FileInfo and
FileAttributes classes to do exactly the same thing. However it appears that
these .NET Framework classes do not accept the long file name prefix in the
path so the program cannot set the attributes of files or folders with long
names.

Is there any other method for returning FileInfo objects for files with long
names other than calling the FindFirstFile and FindFindNextFile from the
VB.NET program
 
T

TerryFei

Hi Ade,
Welcome to MSDN Newsgroup!

Net Framework don't support name prefix. As a workaround for this issue,
we should modify this file/directory name manually at first and then pass
modified name in the relevant method. Just like:
Convert "\\?\c:\<path>" to "c:\<path>"
Convert "\\?\UNC\<server>\<share>\". to "\\<server>\<share>\".

The following article is about how to operate files using c#. I hope it's
useful for you:
Title: File Information using C#
URL: http://www.codeproject.com/csharp/file_operations.asp

I hope the above information is helpful for you. Thanks and have a nice day!

Best Regards,

Terry Fei [MSFT]
Microsoft Community Support
Get Secure! www.microsoft.com/security


--------------------
 
G

Guest

Hi Terry,

Thanks for your reply. That is disappointing as I am trying to encourage
the use of .NET by converting old programs to .NET when we get requests to
modify them. I assume this apply to Framework 2.0 as well.

I am going to have to carry on using the old Windows API program as the
program processes the files automatically via a scheduled task that runs
overnight. The user will not think that having to manually modify long file
names is a step forward.

Regards
Ade

"TerryFei" said:
Hi Ade,
Welcome to MSDN Newsgroup!

.Net Framework don't support name prefix. As a workaround for this issue,
we should modify this file/directory name manually at first and then pass
modified name in the relevant method. Just like:
Convert "\\?\c:\<path>" to "c:\<path>"
Convert "\\?\UNC\<server>\<share>\". to "\\<server>\<share>\".

The following article is about how to operate files using c#. I hope it's
useful for you:
Title: File Information using C#
URL: http://www.codeproject.com/csharp/file_operations.asp

I hope the above information is helpful for you. Thanks and have a nice day!

Best Regards,

Terry Fei [MSFT]
Microsoft Community Support
Get Secure! www.microsoft.com/security


--------------------
 
T

TerryFei

Hi Ade,
Thanks for your response! :)

It's your kind of feedback that let's know what things you're trying to do,
that we haven't yet exposed for you. I'll forward this feedback to the
relevant team. We are looking at continual improvement, and Keep the
information coming. Thanks for your understanding!

Best Regards,

Terry Fei [MSFT]
Microsoft Community Support
Get Secure! www.microsoft.com/security

--------------------
Thread-Topic: Retrieving info on files with a long name using .NET
thread-index: AcY1/X6mF3ji3NvbRDKppoytcb9hhQ==
X-WBNR-Posting-Host: 212.125.64.198
From: =?Utf-8?B?QWRl?= <[email protected]>
References: <[email protected]>
Subject: RE: Retrieving info on files with a long name using .NET
Date: Mon, 20 Feb 2006 01:10:29 -0800
Lines: 90
Message-ID: <[email protected]>
MIME-Version: 1.0
Content-Type: text/plain;
charset="Utf-8"
Content-Transfer-Encoding: 8bit
X-Newsreader: Microsoft CDO for Windows 2000
Content-Class: urn:content-classes:message
Importance: normal
Priority: normal
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
Newsgroups: microsoft.public.dotnet.framework
NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGXA03.phx.gbl
Xref: TK2MSFTNGXA01.phx.gbl microsoft.public.dotnet.framework:108890
X-Tomcat-NG: microsoft.public.dotnet.framework

Hi Terry,

Thanks for your reply. That is disappointing as I am trying to encourage
the use of .NET by converting old programs to .NET when we get requests to
modify them. I assume this apply to Framework 2.0 as well.

I am going to have to carry on using the old Windows API program as the
program processes the files automatically via a scheduled task that runs
overnight. The user will not think that having to manually modify long file
names is a step forward.

Regards
Ade

"TerryFei" said:
Hi Ade,
Welcome to MSDN Newsgroup!

.Net Framework don't support name prefix. As a workaround for this issue,
we should modify this file/directory name manually at first and then pass
modified name in the relevant method. Just like:
Convert "\\?\c:\<path>" to "c:\<path>"
Convert "\\?\UNC\<server>\<share>\". to "\\<server>\<share>\".

The following article is about how to operate files using c#. I hope it's
useful for you:
Title: File Information using C#
URL: http://www.codeproject.com/csharp/file_operations.asp

I hope the above information is helpful for you. Thanks and have a nice day!

Best Regards,

Terry Fei [MSFT]
Microsoft Community Support
Get Secure! www.microsoft.com/security


--------------------
Thread-Topic: Retrieving info on files with a long name using .NET
thread-index: AcYz2wNlfo7ZPyXHQgK9IhsCcCUCrw==
X-WBNR-Posting-Host: 212.125.64.198
From: =?Utf-8?B?QWRl?= <[email protected]>
Subject: Retrieving info on files with a long name using .NET
Date: Fri, 17 Feb 2006 07:58:37 -0800
Lines: 18
Message-ID: <[email protected]>
MIME-Version: 1.0
Content-Type: text/plain;
charset="Utf-8"
Content-Transfer-Encoding: 8bit
X-Newsreader: Microsoft CDO for Windows 2000
Content-Class: urn:content-classes:message
Importance: normal
Priority: normal
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
Newsgroups: microsoft.public.dotnet.framework
NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGXA03.phx.gbl
Xref: TK2MSFTNGXA01.phx.gbl microsoft.public.dotnet.framework:108816
X-Tomcat-NG: microsoft.public.dotnet.framework

I had previously written a program to set the attributes of all files in a
folder. The program uses the Windows API functions FindFirstFile and
FindFindNextFile to process the files in a specified folder and its
sub-folders. By specify the prefix “\\?\UNC\ââ‚?or “\\?\Ã
¢â‚?files or
folders
with names longer than 260 characters are processed. I have now written a
VB.NET 2003 equivalent using.NET Framework version 1.1. The program
uses
the
Directory class methods GetDirectories and GetFiles, and the FileInfo and
FileAttributes classes to do exactly the same thing. However it
appears
that
these .NET Framework classes do not accept the long file name prefix in the
path so the program cannot set the attributes of files or folders with long
names.

Is there any other method for returning FileInfo objects for files with long
names other than calling the FindFirstFile and FindFindNextFile from the
VB.NET program
 
G

Guest

Thanks.
--
Ade


"TerryFei" said:
Hi Ade,
Thanks for your response! :)

It's your kind of feedback that let's know what things you're trying to do,
that we haven't yet exposed for you. I'll forward this feedback to the
relevant team. We are looking at continual improvement, and Keep the
information coming. Thanks for your understanding!

Best Regards,

Terry Fei [MSFT]
Microsoft Community Support
Get Secure! www.microsoft.com/security

--------------------
Thread-Topic: Retrieving info on files with a long name using .NET
thread-index: AcY1/X6mF3ji3NvbRDKppoytcb9hhQ==
X-WBNR-Posting-Host: 212.125.64.198
From: =?Utf-8?B?QWRl?= <[email protected]>
References: <[email protected]>
Subject: RE: Retrieving info on files with a long name using .NET
Date: Mon, 20 Feb 2006 01:10:29 -0800
Lines: 90
Message-ID: <[email protected]>
MIME-Version: 1.0
Content-Type: text/plain;
charset="Utf-8"
Content-Transfer-Encoding: 8bit
X-Newsreader: Microsoft CDO for Windows 2000
Content-Class: urn:content-classes:message
Importance: normal
Priority: normal
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
Newsgroups: microsoft.public.dotnet.framework
NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGXA03.phx.gbl
Xref: TK2MSFTNGXA01.phx.gbl microsoft.public.dotnet.framework:108890
X-Tomcat-NG: microsoft.public.dotnet.framework

Hi Terry,

Thanks for your reply. That is disappointing as I am trying to encourage
the use of .NET by converting old programs to .NET when we get requests to
modify them. I assume this apply to Framework 2.0 as well.

I am going to have to carry on using the old Windows API program as the
program processes the files automatically via a scheduled task that runs
overnight. The user will not think that having to manually modify long file
names is a step forward.

Regards
Ade

"TerryFei" said:
Hi Ade,
Welcome to MSDN Newsgroup!

.Net Framework don't support name prefix. As a workaround for this issue,
we should modify this file/directory name manually at first and then pass
modified name in the relevant method. Just like:
Convert "\\?\c:\<path>" to "c:\<path>"
Convert "\\?\UNC\<server>\<share>\". to "\\<server>\<share>\".

The following article is about how to operate files using c#. I hope it's
useful for you:
Title: File Information using C#
URL: http://www.codeproject.com/csharp/file_operations.asp

I hope the above information is helpful for you. Thanks and have a nice day!

Best Regards,

Terry Fei [MSFT]
Microsoft Community Support
Get Secure! www.microsoft.com/security


--------------------
Thread-Topic: Retrieving info on files with a long name using .NET
thread-index: AcYz2wNlfo7ZPyXHQgK9IhsCcCUCrw==
X-WBNR-Posting-Host: 212.125.64.198
From: =?Utf-8?B?QWRl?= <[email protected]>
Subject: Retrieving info on files with a long name using .NET
Date: Fri, 17 Feb 2006 07:58:37 -0800
Lines: 18
Message-ID: <[email protected]>
MIME-Version: 1.0
Content-Type: text/plain;
charset="Utf-8"
Content-Transfer-Encoding: 8bit
X-Newsreader: Microsoft CDO for Windows 2000
Content-Class: urn:content-classes:message
Importance: normal
Priority: normal
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
Newsgroups: microsoft.public.dotnet.framework
NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGXA03.phx.gbl
Xref: TK2MSFTNGXA01.phx.gbl microsoft.public.dotnet.framework:108816
X-Tomcat-NG: microsoft.public.dotnet.framework

I had previously written a program to set the attributes of all files in a
folder. The program uses the Windows API functions FindFirstFile and
FindFindNextFile to process the files in a specified folder and its
sub-folders. By specify the prefix “\\?\UNC\ââ‚?or “\\?\à ¢â‚?files or
folders
with names longer than 260 characters are processed. I have now written a
VB.NET 2003 equivalent using.NET Framework version 1.1. The program uses
the
Directory class methods GetDirectories and GetFiles, and the FileInfo and
FileAttributes classes to do exactly the same thing. However it appears
that
these .NET Framework classes do not accept the long file name prefix in
the
path so the program cannot set the attributes of files or folders with
long
names.

Is there any other method for returning FileInfo objects for files with
long
names other than calling the FindFirstFile and FindFindNextFile from the
VB.NET program
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top