c# - GetDirectories invalid characters

  • Thread starter Thread starter Steph
  • Start date Start date
S

Steph

hello,
i want copy a macintoch cdrom... but some file have invalid characters.
so i want no copy this files.
but how do ?


foreach (FileSystemInfo fsi in di.GetFileSystemInfos())
or
foreach (DirectoryInfo tmpdi in di.GetDirectories())

return an error (argumentexception) and stop the process !!!

please help !
 
hello,
i want copy a macintoch cdrom... but some file have invalid characters.

What kind of "invalid characters"?
so i want no copy this files.
but how do ?

foreach (FileSystemInfo fsi in di.GetFileSystemInfos())
or
foreach (DirectoryInfo tmpdi in di.GetDirectories())

return an error (argumentexception) and stop the process !!!

Can you give the exact error message, and a complete full stack, for
that ArgumentException?
 
by example : "*" or other special macintosh authorized chars file name

in fact it will file ... the goal is to reach around the ArgumentException
 
by example : "*"  or other special macintosh authorized chars file name

in fact it will file ... the goal is to reach around the ArgumentException

I do not think you can work around that. Your only hope there might be
to try working with Win32 API file functions directly via P/Invoke,
but I strongly suspect that they will fail too - you're just trying to
work with file names that are not valid as far as Windows (not
even .NET) is concerned. If it comes to that, it may be that you'll
have to access the disc data directly, and write your own file-
handling code...
 
Pavel said:
I do not think you can work around that. Your only hope there might be
to try working with Win32 API file functions directly via P/Invoke,
but I strongly suspect that they will fail too - you're just trying to
work with file names that are not valid as far as Windows (not
even .NET) is concerned. If it comes to that, it may be that you'll
have to access the disc data directly, and write your own file-
handling code...

yes windows can open a bad directory, list files, but can not copy...
and .net can do... nothing !
i continue to search
 
i want copy a macintoch cdrom... but some file have invalid characters.
so i want no copy this files.
but how do ?


foreach (FileSystemInfo fsi in di.GetFileSystemInfos())
or
foreach (DirectoryInfo tmpdi in di.GetDirectories())

return an error (argumentexception) and stop the process !!!

Have you tried using Directory.GetFiles() instead? That will just give you a
string array instead of trying to construct FileSystemInfo objects.
Maybe--just maybe--you'll get the all the file names and then you can test
them to see if they contain invalid characters.
 
yes windows can open a bad directory, list files, but can not copy...
and .net can do... nothing !
i continue to search

If by "Windows" you mean "Windows Explorer", then it strongly implies
that at least Win32 APIs for listing directory content (FindFirstFile
& FindNextFile) work correctly. .NET APIs do a lot of sanity checks
when it comes to filenames, which is why they might be failing here
(though you should also try what Jeff suggests). Otherwise, I can only
repeat my earlier suggestion - use P/Invoke to call FindFirstFile/
FindNextFile directly.
 
Pavel said:
If by "Windows" you mean "Windows Explorer", then it strongly implies
that at least Win32 APIs for listing directory content (FindFirstFile
& FindNextFile) work correctly. .NET APIs do a lot of sanity checks
when it comes to filenames, which is why they might be failing here
(though you should also try what Jeff suggests). Otherwise, I can only
repeat my earlier suggestion - use P/Invoke to call FindFirstFile/
FindNextFile directly.

I WILL TRY
see you a next time !!!
 
Jeff said:
Have you tried using Directory.GetFiles() instead? That will just give you a
string array instead of trying to construct FileSystemInfo objects.
Maybe--just maybe--you'll get the all the file names and then you can test
them to see if they contain invalid characters.
identical

the only way : kernel32 !

but i ve a unsafe bug when i call "FindNextFile" and i don't find a good
script (example) on the web...
 
Back
Top