In our series of "probably something simple"...
I am doing a File.Exists operation to check if a file exists. Let's
assume that this file is C:/test.txt.
Now, if I do File.Exists("C:\\Test.txt"), I do not want it to tell me
that the file exists - this is a check for a File.Move operation (some
file renaming functionality). But if I check C:\\test.txt, it should
return true.
Any suggestions? 8 12157
Sweetiecakes wrote:
In our series of "probably something simple"...
I am doing a File.Exists operation to check if a file exists. Let's
assume that this file is C:/test.txt.
Now, if I do File.Exists("C:\\Test.txt"), I do not want it to tell me
that the file exists - this is a check for a File.Move operation (some
file renaming functionality). But if I check C:\\test.txt, it should
return true.
Any suggestions?
Sweetiecakes,
the question does not make mush sense you are saying you dont want it to
tel you if the file esists but the it should return true;
File.Exists() returns a boolean (true or false) if the file exists it
returns true otherwise false.
if you want to check a folder to make sure a file with that name does
not exist you could do:
if(!File.Exists(destpath)){
//move
}
else{
//do whatever you want
}
DH wrote:
Sweetiecakes,
the question does not make mush sense you are saying you dont want it to
tel you if the file esists but the it should return true;
File.Exists() returns a boolean (true or false) if the file exists it
returns true otherwise false.
if you want to check a folder to make sure a file with that name does
not exist you could do:
if(!File.Exists(destpath)){
//move
}
else{
//do whatever you want
}
I don't know what I've been typing in my last message - but basically,
what I meant, was that I want the File.Exists() command to be
_case-sensitive_, so that test.txt and Test.txt are not the same thing
(such as in an Unix environment).
Thanks
I don't know what I've been typing in my last message - but basically,
what I meant, was that I want the File.Exists() command to be
_case-sensitive_, so that test.txt and Test.txt are not the same thing
(such as in an Unix environment).
Thanks
Sweetiecakes wrote:
DH wrote:
>Sweetiecakes, the question does not make mush sense you are saying you dont want it to tel you if the file esists but the it should return true; File.Exists() returns a boolean (true or false) if the file exists it returns true otherwise false.
if you want to check a folder to make sure a file with that name does not exist you could do: if(!File.Exists(destpath)){ //move } else{ //do whatever you want }
I don't know what I've been typing in my last message - but basically,
what I meant, was that I want the File.Exists() command to be
_case-sensitive_, so that test.txt and Test.txt are not the same thing
(such as in an Unix environment).
Thanks
That is not going to be possible in a windows environment. In windows
test.txt and Test.txt are the same thing. so unless ur using a *nix
environment in windows you will never have test.txt and Test.txt in the
same directory.
"Sweetiecakes" <x@x.comwrote in message
news:49***********************@news.fv.fi...
I don't know what I've been typing in my last message - but basically,
what I meant, was that I want the File.Exists() command to be
_case-sensitive_, so that test.txt and Test.txt are not the same thing
(such as in an Unix environment).
I would say you should try to create a FileInfo object and then (assuming
Exists returns true) test its Name property against your original string in
a case-sensitive manner. This is off the top of my head, and I can't be
positive that the FileInfo object will return the properly-cased file name
in the Name property or if it will simply parrot what you put in, but my gut
feeling is that you'll get the real file name. Try it.
Sweetiecakes wrote:
I don't know what I've been typing in my last message - but basically,
what I meant, was that I want the File.Exists() command to be
_case-sensitive_, so that test.txt and Test.txt are not the same thing
(such as in an Unix environment).
Thanks
I guess if you really want to make it case sensitive you could use
Directory.GetFiles()
and go through the files and check them but this is going to be slow and
inefficient if the folder has a lot of files.
Sweetiecakes wrote:
I don't know what I've been typing in my last message - but basically,
what I meant, was that I want the File.Exists() command to be
_case-sensitive_, so that test.txt and Test.txt are not the same thing
(such as in an Unix environment).
I am very sure that trying to use NTFS as a case sensitive file system
will be a disaster.
But if you insist, then try:
public static class MyFile
{
public static bool MyExists(string fnm)
{
if(!File.Exists(fnm)) return false;
return
Array.Exists(Directory.GetFiles(Path.GetDirectoryN ame(fnm)), s =s ==
Path.GetFullPath(fnm));
}
}
Arne
"Arne Vajhøj" <ar**@vajhoej.dkwrote in message news:49***********************@news.sunsite.dk...
Sweetiecakes wrote:
>I don't know what I've been typing in my last message - but basically,
what I meant, was that I want the File.Exists() command to be
_case-sensitive_, so that test.txt and Test.txt are not the same thing
(such as in an Unix environment).
I am very sure that trying to use NTFS as a case sensitive file system
will be a disaster.
Right -- to underscore that point -- Windows NTFS is *not* a case-sensitive file system and you will find discrepancies from one machine to another as to how case is handled. Under Windows, if test.txt exists, then so does Test.Txt, because they are the same file. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Xah Lee |
last post by:
is there a way to condense the following loop into one line?
# -*- coding: utf-8 -*-
# python
import re, os.path
imgPaths=
# change the image path to the full sized image, if it exists
|
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...
|
by: comp.lang.php |
last post by:
class ReportGenerator {
function ReportGenerator() {}
/**
* Generate the HTTP headers necessary for this file type. Can be
called statically
*
|
by: OdAwG |
last post by:
Hello All,
I would i check to see if a file exist and if it does exist, then rename the
file with the date and time attached to the name:
Example:
If...
|
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:
...
|
by: CCLeasing |
last post by:
If (Directory.Exists(@"c:\indigo\" + txtOfficial + @"\" +
comOffice.Text + @"\" + numTerm.Value.ToString()))
{
storereport();
}
else
{
Directory.CreateDirectory(@"c:\indigo\" + txtOfficial +...
|
by: B. Williams |
last post by:
I need some assistance with random access file processing. I have a function
that I would like to change from sequential file processing to random
access. Thanks in advance.
void...
|
by: snow |
last post by:
Hi All,
I noticed if file path has a white space, for example "C:\my document
\test.txt", the function File.Exists(filePath) always return false in
release mode. How could I make this function...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
| |