473,396 Members | 2,158 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How to scan a file with a long path (more than 256 characters)

I write a program in c#. This program run in my computer (window 7 os) scans the file in the file server(linux os). When the path of file very long, >256 charaters. The program stop run and throw a longpathexception.

How can I solve this problem?

Thank you every one!

Expand|Select|Wrap|Line Numbers
  1.  
  2. private static void scanFile(string directory)
  3.         {
  4.             List<FileInfo> fileList = new List<FileInfo>();
  5.  
  6.             System.IO.DirectoryInfo di = new DirectoryInfo(directory);
  7.  
  8.             FileInfo[] files = di.GetFiles("*", SearchOption.TopDirectoryOnly);
  9.             DirectoryInfo[] directories = di.GetDirectories("*", SearchOption.TopDirectoryOnly);
  10.  
  11.  
  12.             foreach (FileInfo file in files)
  13.             {
  14.                 fileList.Add(file);
  15.                 logger.Info("Got file: " + file);
  16.             }
  17.  
  18.             inputData(fileList);
  19.  
  20.             foreach (DirectoryInfo dir in directories)
  21.             {
  22.                 scanFile(dir.FullName);
  23.             }
  24.  
  25.             return;
  26.         }//end scanFile method.
  27.  
  28.  
  29.  
Oct 25 '10 #1
0 1175

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Matt Sawyer | last post by:
I am attempting to use an API (CxApiOem.dll) that has a large number of defines and complicated structs. It's just too much hassle to attempt to use DLLImport to make the desired API calls. ...
6
by: I am Sam | last post by:
I keep getting this error and I don't know why: The path is too long after being fully qualified. Make sure path is less than 260 characters. Description: An unhandled exception occurred...
8
by: Todd | last post by:
I am writing a method to do some standard conversions on the text of a file. However, I am having difficulty getting the StreamReader and StreamWriter to behave. The input file is a Visual Studio...
3
by: Zenu | last post by:
Hi, I have a system with very long paths and I'm trying to use file.exist(Longpath) to test the paths existance but it gives a message that the path is too long. Can someone tell me how to...
1
by: eyal | last post by:
Hello I'm getting an error while working with the FS - "The path is too long after being fully qualified. Make sure path is less than 260 characters". I'm looking for a working sample or...
1
by: Bigrabid | last post by:
Howdy, I have an access database that I use to keep track of projects that my group is working on. There are a number of files associated with any one project, so I have as a parent to , which...
1
by: imartins | last post by:
I need to create a program in c which creates a file of 10 single Characters. The program should have 2 command line args: the number of chars to write to the file, and the first char of the...
34
by: Alexnb | last post by:
Gerhard Häring wrote: No, it didn't work, but it gave me some interesting feedback when I ran it in the shell. Heres what it told me: Traceback (most recent call last): File...
1
by: Stefan Pascal | last post by:
Hello. I have a very strange problem on my system with running C# applications from a longer than usual (>127 chars) path. I was able to reproduce the following 2 cases: 1. Socket s = new...
0
by: theindescribablehunk | last post by:
Hi, I previously used DirectoryInfo objects to access the DirectorySecurity object so i could enumerate the ACL for specific directories. Unfortunately the DirectoryInfo object doesn't support...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.