473,769 Members | 1,723 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

File.Exists(fil ePath) always returns false in release mode if filePath contains a white space

Hi All,

I noticed if file path has a white space, for example "C:\my document
\test.txt", the function File.Exists(fil ePath) always return false in
release mode. How could I make this function work for the file which
is located in a direcotry with a white space?

Thanks!

Feb 12 '07
12 4568
I think that all you need to do is replace all " in the command argument
with string.empty.

A quote is not a valid character for folder or file names so you can do this
and it should work correctly.

LS

"snow" <ba**********@y ahoo.comwrote in message
news:11******** **************@ v45g2000cwv.goo glegroups.com.. .
On Feb 12, 1:57 pm, "Lloyd Sheen" <a...@b.cwrot e:
>Please make sure that you don't have the quotes in the string you are
sending. I would advise to put up a msgbox just prior to the file.exists
call. I have never seen this fail.

LS"snow" <barbara_d...@y ahoo.comwrote in message

news:11******* *************** @j27g2000cwj.go oglegroups.com. ..
On Feb 12, 1:01 pm, "Lloyd Sheen" <a...@b.cwrot e:
I have lots of directories with that case and have never seen what you
describe. Ensure that the folder name is correct. What dot.net
version
are
you targeting?
>LS
>"snow" <barbara_d...@y ahoo.comwrote in message
>>news:11****** *************** *@m58g2000cwm.g ooglegroups.com ...
I am using .net frame work 1.0 with VS.net 2003. The file path is
defined by the command line. It doesn't matter it is a special folder
or not. if only the directory name contains a white space, like "C:\my
file\test.txt", "C:\test file\test.txt", the function
File.Exists(fil ePath) always return false, even the file exists in
that direcotry.
Hi All,
I noticed if file path has a white space, for example "C:\my
document
\test.txt", the function File.Exists(fil ePath) always return false
in
release mode. How could I make this function work for the file which
is located in a direcotry with a white space?
Thanks!- Hide quoted text -
>- Show quoted text -- Hide quoted text -

- Show quoted text -

Thanks for the advice. You are right, if I delete the quotes around
the file path on the command line, it works! but I still have the
problem in the following case. If I drag the file from the window
explorer and drop it to the program exe icon on the desktop, I still
got "File not Found", the reason is the file path was added quotes
automaticlly. How to make drag and drop the file work with white space
in the file path? I am using Microsoft.Visua lBasic.Command( ) to
capture the file path.
Feb 13 '07 #11
On Feb 12, 4:23 pm, "Lloyd Sheen" <a...@b.cwrot e:
I think that all you need to do is replace all " in the command argument
with string.empty.

A quote is not a valid character for folder or file names so you can do this
and it should work correctly.

LS

"snow" <barbara_d...@y ahoo.comwrote in message

news:11******** **************@ v45g2000cwv.goo glegroups.com.. .
On Feb 12, 1:57 pm, "Lloyd Sheen" <a...@b.cwrot e:
Please make sure that you don't have the quotes in the string you are
sending. I would advise to put up a msgbox just prior to the file.exists
call. I have never seen this fail.
LS"snow" <barbara_d...@y ahoo.comwrote in message
>news:11******* *************** @j27g2000cwj.go oglegroups.com. ..
On Feb 12, 1:01 pm, "Lloyd Sheen" <a...@b.cwrot e:
I have lots of directories with that case and have never seen what you
describe. Ensure that the folder name is correct. What dot.net
version
are
you targeting?
LS
"snow" <barbara_d...@y ahoo.comwrote in message
>news:11******* *************** @m58g2000cwm.go oglegroups.com. ..
I am using .net frame work 1.0 with VS.net 2003. The file path is
defined by the command line. It doesn't matter it is a special folder
or not. if only the directory name contains a white space, like "C:\my
file\test.txt", "C:\test file\test.txt", the function
File.Exists(fil ePath) always return false, even the file exists in
that direcotry.
Hi All,
I noticed if file path has a white space, for example "C:\my
document
\test.txt", the function File.Exists(fil ePath) always return false
in
release mode. How could I make this function work for the file which
is located in a direcotry with a white space?
Thanks!- Hide quoted text -
- Show quoted text -- Hide quoted text -
- Show quoted text -
Thanks for the advice. You are right, if I delete the quotes around
the file path on the command line, it works! but I still have the
problem in the following case. If I drag the file from the window
explorer and drop it to the program exe icon on the desktop, I still
got "File not Found", the reason is the file path was added quotes
automaticlly. How to make drag and drop the file work with white space
in the file path? I am using Microsoft.Visua lBasic.Command( ) to
capture the file path.- Hide quoted text -

- Show quoted text -
Thanks! it works now.

Feb 13 '07 #12

I am so sorry; call me ignorant

can you even use the 1.0 framework with VS.net 2003?

grow a clue, kid

DOTNET sucks a big fat hairy cock and MS is preparing 'yet another
visual fred'

now is the time for action, kids
LIFE IS DOTNOT PEACHY

On Feb 12, 1:24 pm, "snow" <barbara_d...@y ahoo.comwrote:
On Feb 12, 1:01 pm, "Lloyd Sheen" <a...@b.cwrote: I have lots of directories with that case and have never seen what you
describe. Ensure that the folder name is correct. What dot.net version are
you targeting?
LS
"snow" <barbara_d...@y ahoo.comwrote in message
news:11******** **************@ m58g2000cwm.goo glegroups.com.. .

I am using .net frame work 1.0 with VS.net 2003. The file path is
defined by the command line. It doesn't matter it is a special folder
or not. if only the directory name contains a white space, like "C:\my
file\test.txt", "C:\test file\test.txt", the function
File.Exists(fil ePath) always return false, even the file exists in
that direcotry.


Hi All,
I noticed if file path has a white space, for example "C:\my document
\test.txt", the function File.Exists(fil ePath) always return false in
release mode. How could I make this function work for the file which
is located in a direcotry with a white space?
Thanks!- Hide quoted text -
- Show quoted text -- Hide quoted text -

- Show quoted text -

Feb 14 '07 #13

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1349
by: Masiar Farahani | last post by:
Hi, Is there a option in PythonWin to write files in unix file mode? Regards Masiar
2
12523
by: Rob Manger | last post by:
Hi Guys, Urgent problem. Trying to compile my solution I get the following error: Linking... LINK: fatal error LNK1181: cannot open input file 'Release\icmpping.abj' Note, I havn't changed anything. This project was developed on another computer that is setup exactly the same way.
1
1335
by: laurie | last post by:
Hi. Does anyone know of a simple asp script that can check free disk space and send an email to someone when low disk space occurs? I am not familiar with asp. I am from a php background but our server doesn't support php only asp. Thanks Laurie
4
20309
by: eva.monsen | last post by:
I'm trying to run a .BAT file using System.Diagnostics.Process. I'm having trouble getting Process.ExitCode to match up with what the .BAT file returns. Here are the contents of C:\temp\ConsoleApplication1\ConsoleApplication1\test1.bat: exit /B 6 Here is some C# code:
4
13448
by: Italian Pete | last post by:
Hi, I have a website sitting on a server (ServerA) with images to be displayed sitting on a separate server (ServerB) on the same network. I am trying to test for the existance of an image using: File.Exists(Server.Path("/images/" + "myImage.jpg") where the folder "images" is the virtual folder where the images are stored.
10
6645
by: ganeshp | last post by:
Below given is the code to check if a file exists. This code works on Windows but on Linux it fails even when the file exists. Please let me know if you have a solution or a work around for this. Has anybody experienced the same problem. boolean DoesTheFileExist(String filePath) { File fp = new File(filePath); if(true == fp.exists())
14
16366
by: Steve K. | last post by:
I have a method that I use to get a System.Drawing.Image from a file without keeping a handle on the file open (so I can delete the file). Here is the code: <code> public static Image ImageFromFileReleaseHandle(string filename) { FileStream fs = null; try {
10
1693
by: globalrev | last post by:
print os.path.exists('C:\Users\saftarn\Desktop\NetFlixDataSet \trainingsetunzipped\training_set\mv_0000001.txt') d=open('C:/Python25/myPrograms/mapexperiments/maps/provinces-of- sweden.gif') d.close() exists returns false but when i open it doesnt complain. how come? another file that exists returned false for complained when i tried to
1
1679
by: Samuel R. Neff | last post by:
I have a file in a directory that is returned from Directory.GetFiles() but subsequently fails a File.Exists() check. Test code: string p = @"C:\documents and settings\all users\" + @"application data\macromedia\fms"; foreach(string path in Directory.GetFiles(p)) { if ( ! File.Exists(path)) { foreach(char c in Path.GetFileName(path)) {
0
9589
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, 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...
0
9423
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10211
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, 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...
0
10045
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 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...
1
9994
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,...
0
9863
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 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...
0
5447
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3561
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2815
bsmnconsultancy
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...

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.