Hi. I'm writing a little c# program to list all the files in a
selected directory longer than a given size. The problem is that when
it finds a file that is too long for Windows, I get the
PathTooLongExce ption error. I try to handle the exception, but can't
do anything because, well, the file is too long. I can see what and
where the offending file is in the Locals window, so .NET can obviously
read the file path, but I can't write that to any variable. Any
suggestions? (And how certain files that are too long get there in the
first place is another question for another day...) Following is an
outline of my code:
* user selects a directory from a treeview
* code calls the AddFilesToList method which iterates through the files
in the chosen directory
* when files are longer than e.g. 100 characters the file name is
written to an arraylist
* the subfolders of the chosen directory are iterated through each
recursively calling AddFilesToList
And the AddFilesToList method. (For some reason the spaces at the
start of lines aren't coming out, so I hope this is worth something.)
private void AddFilesToList( DirectoryInfo dir)
{
FileInfo[] files = dir.GetFiles();
DirectoryInfo[] subdirs = dir.GetDirector ies();
foreach(FileInf o fi in files)
{
try
{
if(fi.FullName. Length >
Convert.ToInt32 (txtFileLengthC utoff.Text))
{
Debug.WriteLine ("try file: " + fi.FullName);
longFiles.Add(f i.FullName); // this is the arraylist
}
}
catch (System.IO.Path TooLongExceptio n e)
{
Debug.WriteLine ("catch file: " + fi.FullName);
// string temp = fi.DirectoryNam e;
// temp = fi.FullName;
longFiles.Add(f i.FullName);
}
}
foreach (DirectoryInfo di in subdirs)
{
AddFilesToList( di);
}
}
Thanks for any help,
Justin 4 3929
Thanks Chris. I had tried exploring the PathTooLongExce ption, but
didn't find anything useful. The e.Message gives the same message that
prints out, and the InnerException gives nothing because it's null. I
know the information exists somewhere because as I said, I can see the
offending file in the Locals window as I'm debugging the code. Thanks
for the reply.
Justin
Thanks Chris. I had tried exploring the PathTooLongExce ption, but
didn't find anything useful. The e.Message gives the same message that
prints out, and the InnerException gives nothing because it's null. I
know the information exists somewhere because as I said, I can see the
offending file in the Locals window as I'm debugging the code. Thanks
for the reply.
Justin This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: DarthMacgyver |
last post by:
Hello,
I recently wrote a survey application. Each question is very similar.
The first questions gives me a problem when there are multiple people
taking the survey (The Database connection Timed out) I am using the
Data Access Application Blocks as ASP.NET (using VB.NET) and SQL 2000.
In there first question there can be up to 27 answers. So I figured
instead of making 27 different trips to the database I woulc just
concatenate my...
|
by: Shakil Khan |
last post by:
System.IO.PathTooLongException
"The path is too long after being fully qualified. Make sure path is less
than 260 characters"
Can anyone help, How to resolve this issue?
This exception is coming when I m trying to copy such problematic file i.e.
whose path is greater than 260 characters.
I have read on some forums that this issue can't be solved. But then how
MS-Word or other applications are hadling it because you can easily insert...
|
by: Justin |
last post by:
Hi. I'm writing a little c# program to list all the files in a
selected directory longer than a given size. The problem is that when
it finds a file that is too long for Windows, I get the
PathTooLongException error. I try to handle the exception, but can't
do anything because, well, the file is too long. I can see what and
where the offending file is in the Locals window, so .NET can obviously
read the file path, but I can't write...
|
by: ASP newbie |
last post by:
I cannot run my asp.net application in w2k server.
But the program works fine under w2k professional.
Can anyone tell me is there any difference in the settings?
Many thanks.
|
by: Tom |
last post by:
I have a problem, to which I have been unable to find a solution for
days now, after checking numerous references (both in books and
online). Perhaps someone here can help. Here's my problem:
I'm trying to define a series of radio objects as a large array for a
survey, like this:
1) Does this make sense?
<input type="radio" name="question" value="Y"> Yes
<input type="radio" name="question" value="N"> No
| |
by: shrishjain |
last post by:
Hi All,
I call Assembly.LoadFrom("C:\\MyDir\\MyAssembly.dll")- it works fine.
However when I call the following, it fails:
Assembly.LoadFrom("C:\\MyDir\\..\\MyDir\\..\\MyDir\\..\\MyDir\\..\\MyDir\\..\\MyDir\\
...\\MyDir\\..\\MyDir\\..\\MyDir\\..\\MyDir\\..\\MyDir\\..\\MyDir\\..\\MyDir\\..\\MyDir\\..\\MyDir\\..\\
MyDir\\..\\MyDir\\..\\MyDir\\..\\MyDir\\..\\MyDir\\..\\MyDir\\..\\MyDir\\..\\MyDir\\..\\MyDir\\..\\...
|
by: Johan Delimon |
last post by:
Hello,
Ever got this error?
The specified path, file name, or both are too long. The fully qualified
file name must be less than 260 characters, and the directory name must be
less than 248 characters.
Since the .NET Framework does not support long filenames :-(
I had to write a library that calls the WIN32 API and wraps those functions
like System.IO.
|
by: comp.lang.tcl |
last post by:
My TCL proc, XML_GET_ALL_ELEMENT_ATTRS, is supposed to convert an XML
file into a TCL list as follows:
attr1 {val1} attr2 {val2} ... attrN {valN}
This is the TCL code that does this:
set contents ]; close $fileID
|
by: mjheitland |
last post by:
When I pass my directories recursively on a directory structure with
paths 260 chars I get the following exception (see line marked with
***), although I am using only ShortPathNames through Win32API
function::
The specified path, file name, or both are too long. The fully
qualified file name must be less than 260 characters, and the
directory name must be less than 248 characters.
My short path names are < 255 characters, but...
|
by: Gillard |
last post by:
hi ,
i try to
io.file.delete(startmenushortcut)
i get PathTooLongException
how to delete those dead links in my start menu
please
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |