I have a file in a directory that is returned from
Directory.GetFi les() but subsequently fails a File.Exists() check.
Test code:
string p = @"C:\documen ts and settings\all users\" +
@"applicatio n data\macromedia \fms";
foreach(string path in Directory.GetFi les(p)) {
if ( ! File.Exists(pat h)) {
foreach(char c in Path.GetFileNam e(path)) {
Console.WriteLi ne((int)c);
}
}
}
prints out this:
160
160
160
32
160
160
160
That's the real directory, the one file in it was created by Flash
Media Server and is very small, just has some numbers in it followed
by a null-byte. In explorer the name looks like it's blank. I can
open it in other apps (Notepad), but in .NET I get
FileNotFoundExc eption trying to access it.
Any explanation as to what .NET is doing here? This has got to be a
bug, right?
Working with .NET 2.0.
Thanks,
Sam
------------------------------------------------------------
We're hiring! B-Line Medical is seeking .NET
Developers for exciting positions in medical product
development in MD/DC. Work with a variety of technologies
in a relaxed team environment. See ads on Dice.com. 1 1673
"Samuel R. Neff" wrote:
I have a file in a directory that is returned from
Directory.GetFi les() but subsequently fails a File.Exists() check.
Test code:
string p = @"C:\documen ts and settings\all users\" +
@"applicatio n data\macromedia \fms";
foreach(string path in Directory.GetFi les(p)) {
if ( ! File.Exists(pat h)) {
foreach(char c in Path.GetFileNam e(path)) {
Console.WriteLi ne((int)c);
}
}
}
prints out this:
160
160
160
32
160
160
160
That's the real directory, the one file in it was created by Flash
Media Server and is very small, just has some numbers in it followed
by a null-byte. In explorer the name looks like it's blank. I can
open it in other apps (Notepad), but in .NET I get
FileNotFoundExc eption trying to access it.
Any explanation as to what .NET is doing here? This has got to be a
bug, right?
Working with .NET 2.0.
Thanks,
Sam
------------------------------------------------------------
We're hiring! B-Line Medical is seeking .NET
Developers for exciting positions in medical product
development in MD/DC. Work with a variety of technologies
in a relaxed team environment. See ads on Dice.com.
Hi Samuel,
I'm inclined to think this is a bug, although there may be a security
reasons behind. (char)160 and (char)32 are valid file characters, yet deep
inside System.IO the path is normalized with a string.TrimEnd( ). Since
(char)160 and (char)32 are whitespace characters the resulting filename will
be blank.
I've submitted a bugreport for this you can follow to see if Microsoft
acknowledges it as a bug https://connect.microsoft.com/Visual...dbackID=373295
--
Happy Coding!
Morten Wennevik [C# MVP] This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: matt |
last post by:
I have compiled some code, some written by me, some compiled from
various sources online, and basically i've got a very simple flat file
photo gallery. An upload form, to upload the photos and give them a
caption, storing the caption and filename in a text file. It's a bit
buggy when removing the photos and captions from the file, and also in
displaying them on the delete page. you can see it in action at
www.4am.com.au/gallery/upload.php...
|
by: Dave Smithz |
last post by:
Hi There,
I have a PHP script that sends an email with attachment and works great when
provided the path to the file to send.
However this file needs to be on the same server as the script.
I want to develop a webpage where people can send attachments that are
stored on their local PC.
|
by: matt dittman |
last post by:
I have created a windows service that reads emails from a
drop directory and moves them to the appropriate mail
folder every 15 seconds. I can move, rename and delete
the files as needed, up until the
CDO.DropDirectory.GetMessages() method is called. At
this point, the files are locked until I shut down the
service. After processing and delivery, I need to be
able to delete all the files in the drop directory.
I can delete them via...
|
by: Dan |
last post by:
I have code like the following to test for existence of a file. I know the
file is there, but File.Exists returns FALSE. The problem appears to be
that the file is in a directory beneath "My Documents". When I move it to a
directory directly under the root, File.Exists returns TRUE. So I tried
using FileIOPermission to give me rights to read it, but still no luck. Any
suggestions? Thanks...
FileIOPermission f = new...
|
by: Lokkju |
last post by:
I am pretty much lost here - I am trying to create a managed c++
wrapper for this dll, so that I can use it from c#/vb.net, however, it
does not conform to any standard style of coding I have seen. It is
almost like it is trying to implement it's own COM interfaces...
below is the header, and a link to the dll+code:
Zip file with header, example, and DLL:...
| |
by: Sky Sigal |
last post by:
I have created an IHttpHandler that waits for uploads as attachments for a
webmail interface, and saves it to a directory that is defined in
config.xml.
My question is the following:
assuming that this is suppossed to end up as a component for others to use,
and therefore I do NOT have access to their global.cs::Session_End()
how do I cleanup files that were uploaded -- but obviously left stranded
when the users aborted/gave up writting...
|
by: Jen |
last post by:
I'm using Microsoft's own VB.NET FTP Example:
http://support.microsoft.com/default.aspx?scid=kb;en-us;832679
I can get the program to create directories, change directories, etc.,
but I can't get it to upload a file to the FTP server. I just get a
"Cannot connect to remote server" error after this TRY:
s = New Socket(AddressFamily.InterNetwork, SocketType.Stream,
ProtocolType.Tcp)
|
by: Jason |
last post by:
I need to open a file for reading, but I only know part of it's name.
The file I want to read is in the format of xxx-yyyy-zzz.EXT
The last three digits of the file name are different on each pc, for example
PC7 has xxx-yyyy-zz1.ext
PC5 has xxx-yyyy-zz2.ext
PC3 has xxx-yyyy-zz8.ext
|
by: laredotornado |
last post by:
Hi,
I'm using PHP 4.4.4 on Apache 2 on Fedora Core 5. PHP was installed
using Apache's apxs and the php library was installed to
/usr/local/php. However, when I set my "error_reporting" setting to be
"E_ALL", notices are still not getting reported. The perms on my file
are 664, with owner root and group root. The php.ini file is located
at /usr/local/lib/php/php.ini. Any ideas why the setting does not seem
to be having an effect? ...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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: 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: 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: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
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...
| |