Hi Group,
I encountered something strange with File.Exists(str ing path). This
function is simply to check whether a file exists in certain path. However,
if the path starts with "file:\" in the begining of the string, no matter
the file exists or not. it will return false without any exception. It is
expected?
Regards,
Alex 6 6019
I'm curious. What version of windows os allows you have "file" as a drive
letter?
"Alex Chan" <Ga********@hot mail.com> wrote in message
news:%2******** ********@TK2MSF TNGP14.phx.gbl. .. Hi Group,
I encountered something strange with File.Exists(str ing path). This function is simply to check whether a file exists in certain path.
However, if the path starts with "file:\" in the begining of the string, no matter the file exists or not. it will return false without any exception. It is expected?
Regards, Alex
Nope. for example, the path like that "file:\c:\temp\ foo.txt" will return
false in every case, while "c:\temp\foo.tx t" wont
"ESPN Lover" <es**@lover.com > wrote in message
news:eD******** ******@TK2MSFTN GP11.phx.gbl... I'm curious. What version of windows os allows you have "file" as a drive letter?
"Alex Chan" <Ga********@hot mail.com> wrote in message news:%2******** ********@TK2MSF TNGP14.phx.gbl. .. Hi Group,
I encountered something strange with File.Exists(str ing path). This function is simply to check whether a file exists in certain path. However, if the path starts with "file:\" in the begining of the string, no
matter the file exists or not. it will return false without any exception. It
is expected?
Regards, Alex
So then what's the issue? If you're checking for a malformed file path, you
should get false. Simply strip off the file:\ from your string
Try this:
if (p.IndexOf(@"fi le:\") == 0)
p = p.Substring(6);
"Alex Chan" <Ga********@hot mail.com> wrote in message
news:em******** ******@TK2MSFTN GP12.phx.gbl... Nope. for example, the path like that "file:\c:\temp\ foo.txt" will return false in every case, while "c:\temp\foo.tx t" wont
"ESPN Lover" <es**@lover.com > wrote in message news:eD******** ******@TK2MSFTN GP11.phx.gbl... I'm curious. What version of windows os allows you have "file" as a
drive letter?
"Alex Chan" <Ga********@hot mail.com> wrote in message news:%2******** ********@TK2MSF TNGP14.phx.gbl. .. Hi Group,
I encountered something strange with File.Exists(str ing path).
This function is simply to check whether a file exists in certain path. However, if the path starts with "file:\" in the begining of the string, no matter the file exists or not. it will return false without any exception. It is expected?
Regards, Alex
Hi,
The reason why i felt that strange is the "file:\" is come with
Path.GetDirecto ryName. My idea is to determine the location of the config
file storing in the current path of the executable through the following
szConfigFileNam e=
Path.GetDirecto ryName(Assembly .GetExecutingAs sembly().CodeBa se) +
"\\Config.x ml";
For this, you will get the path starting with "file:\", and i check that
with File.Exists before opening the file, it always return false and none of
the settings got read.
Actually your suggestion is what i am using.
Regards,
Alex
"ESPN Lover" <es**@lover.com > wrote in message
news:uF******** ******@TK2MSFTN GP11.phx.gbl... So then what's the issue? If you're checking for a malformed file path,
you should get false. Simply strip off the file:\ from your string
Try this: if (p.IndexOf(@"fi le:\") == 0)
p = p.Substring(6); "Alex Chan" <Ga********@hot mail.com> wrote in message news:em******** ******@TK2MSFTN GP12.phx.gbl... Nope. for example, the path like that "file:\c:\temp\ foo.txt" will
return false in every case, while "c:\temp\foo.tx t" wont
"ESPN Lover" <es**@lover.com > wrote in message news:eD******** ******@TK2MSFTN GP11.phx.gbl... I'm curious. What version of windows os allows you have "file" as a drive letter?
"Alex Chan" <Ga********@hot mail.com> wrote in message news:%2******** ********@TK2MSF TNGP14.phx.gbl. .. > Hi Group, > > I encountered something strange with File.Exists(str ing path). This > function is simply to check whether a file exists in certain path. However, > if the path starts with "file:\" in the begining of the string, no matter > the file exists or not. it will return false without any exception.
It is > expected? > > Regards, > Alex > >
Alex Chan wrote: Hi,
The reason why i felt that strange is the "file:\" is come with Path.GetDirecto ryName. My idea is to determine the location of the config file storing in the current path of the executable through the following
szConfigFileNam e= Path.GetDirecto ryName(Assembly .GetExecutingAs sembly().CodeBa se) + "\\Config.x ml";
For this, you will get the path starting with "file:\", and i check that with File.Exists before opening the file, it always return false and none of the settings got read.
Actually your suggestion is what i am using.
Regards,
Alex
"ESPN Lover" <es**@lover.com > wrote in message news:uF******** ******@TK2MSFTN GP11.phx.gbl...
So then what's the issue? If you're checking for a malformed file path,
you
should get false. Simply strip off the file:\ from your string
Try this: if (p.IndexOf(@"fi le:\") == 0)
p = p.Substring(6); "Alex Chan" <Ga********@hot mail.com> wrote in message news:em****** ********@TK2MSF TNGP12.phx.gbl. ..
Nope. for example, the path like that "file:\c:\temp\ foo.txt" will return false in every case, while "c:\temp\foo.tx t" wont
"ESPN Lover" <es**@lover.com > wrote in message news:eD***** *********@TK2MS FTNGP11.phx.gbl ...
I'm curious. What version of windows os allows you have "file" as a
drive
letter?
"Alex Chan" <Ga********@hot mail.com> wrote in message news:%2**** ************@TK 2MSFTNGP14.phx. gbl...
>Hi Group, > > I encountered something strange with File.Exists(str ing path).
This
>function is simply to check whether a file exists in certain path.
However,
>if the path starts with "file:\" in the begining of the string, no
matter
>the file exists or not. it will return false without any exception. It is
>expected ? > > Regards, >Alex > >
Sounds like you're using remoting.
System.IO.File. Exists works on the local machine only. It works the same
way as any other file on a local machine e.g. "c:\hello.t xt"
You MUST be doing something using remoting otherwise it will return the
path on the local machine.
If not you are doing something so strange that I've yet to meet it.
Darwen.
"Alex Chan" <Ga********@hot mail.com> wrote in message
news:uX******** ******@TK2MSFTN GP10.phx.gbl... szConfigFileNam e= Path.GetDirecto ryName(Assembly .GetExecutingAs sembly().CodeBa se) + "\\Config.x ml";
I believe for this, yo'd want:
szConfigFileNam e=
Path.GetDirecto ryName(Server.M apPath(Assembly .GetExecutingAs sembly().CodeBa s
e)) +
"\\Config.x ml";
"file://" is a URL protocol, like "http://" or "ftp://". File.Exist doesn't
understand it. MapPath converts a URL address to a local disk address.
--
Truth,
James Curran
Home: www.noveltheory.com Work: www.njtheater.com
Blog: www.honestillusion.com Day Job: www.partsearch.com
(note new day job!) This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Mike Schinkel |
last post by:
Does anyone know if there are bugs in VBScript's GetRef()? I'm using
VBScript Version 5.6.8515 on Win2003Server w/ASP.
Sometimes it returns an object that VarType() says is a vbObject. Other
times it returns VarType() is vbEmpty. This is driving me mad!
Also, does anyone know what the properties and methods are for the object
returned by GetRef()?
TIA.
|
by: Geiregat Jonas |
last post by:
is using
if(open("file",O_EXCL) != -1){ printf("File does
exists")}else{printf("file does not exists"); }
a good way of checking if a file exists or not, if not how should I do it ?
|
by: StGo |
last post by:
How can i read/write file's custom attributs(like subject,author...) in
C#???
Thanks :))
|
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: Chris Fink |
last post by:
I am using the System.IO.File class to determine if a file exists on a
network share.
The File.Exists method keeps returning false, even though the file does
exist. The MSDN documentation states,
"If the caller does not have sufficient permissions to read the specified
file, no exception is thrown and the method returns false regardless of the
existence of path."
| |
by: DEWright_CA |
last post by:
I am trying to see if a file exists in a virtual directory, and if so run a
method. I try doing File.Exists and the method runs but the file isn't there.
Is there a web version of File.Exists or some otherway to get this type of
functionality without too much heartache???
Thanks
--
D @ premierdata
|
by: paytam |
last post by:
Hi all
Can anyone tell me how can I check that a file exist or no.I mean when
you use this commands
FILE *fp;
if(!fp)
//Could not open the file
doen't show why it can not open it,may be the file doesn't exist.Now
tell me what should I do!
Thanks
|
by: Peter Duniho |
last post by:
I searched using Google, on the web and in the newsgroups, and found nothing
on this topic. Hopefully that means I just don't understand what I'm
supposed to be doing here. :)
The problem:
I am trying to use the SaveFileDialog class to get a filename, which is
subsequently opened for writing (write access, read sharing, but using
read/write sharing doesn't make the problem go away anyway). Sometimes, on
the statement where I...
|
by: PawelSokolowski |
last post by:
Hi all,
Is there any place where can I report bugs in Microsoft products in a way
that gives somethings ?
I mean anyone there cares ?
I was coping with bugs in Visual Studio for years, but I have enough.
After installing Service Pack 1 for .NET 2003 I just cannot stand it.
Simplest things are buggy like never before.
Examples., (those that I have never encountered without Service Pack)
|
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: 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,...
| |
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: 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: 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...
| |