473,385 Members | 1,676 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Problem with File.Exists() method.

I am attempting to copy some files from one machine to
another. I am having difficulty with the File.Exists()
in the code below. The program enumerates the files in a
directory, checks them against a cuttoff DateTime, and
copies them if thet do not already exist. All progress
is written to a log (a snippet is included below the
code). The File.Exists() method returns false even when
the file does in fact exist. Have I coded this
incorrectly?

P.S. This code seems to work on my XP test box, but when
I copy it to the production machine running Windows 2000
server, it fails.
CODE SNIPPET:

for(int i=0; i < sourceFileArray.Length; i++)
{
if(DateTime.Compare(sourceFileArray[i].CreationTime,
cutoffTime) < 0)
{
string destinationFilePath = destinationDir.FullName
+ @"\" + sourceFileArray[i].Name;

this.targetShippingLine.WriteToLog
("DEBUG",destinationFilePath, Convert.ToString(File.Exists
(destinationFilePath)));

if(!File.Exists(destinationFilePath))
{
try
{
sourceFileArray[i].CopyTo(destinationFilePath);
this.targetShippingLine.WriteToLog("LOGCOPY",
sourceFileArray[i].Name, "Sucessfully copied log.");
}
catch (System.Exception e)
{
this.targetShippingLine.WriteToLog
(true, "LOGCOPY", sourceFileArray[i].Name, e.Message);
}
}
}
}

LOG SNIPPET:

DEBUG <some filepath> 10/20/2003 1:55:53 PM
False
ERROR LOGCOPY <some filepath> 10/20/2003 1:55:53 PM
The file <some filepath> already exists.
Jul 21 '05 #1
0 1420

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

Similar topics

25
by: Xah Lee | last post by:
Python Doc Problem Example: gzip Xah Lee, 20050831 Today i need to use Python to compress/decompress gzip files. Since i've read the official Python tutorial 8 months ago, have spent 30...
12
by: SJD | last post by:
I've just read Christoph Schittko's article on XmlSerializer: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnxmlnet/html/trblshtxsd.asp . . . and very informative it is too....
8
by: mytfein | last post by:
Hi Everyone, Background: Another department intends to ftp a .txt file from the mainframe, for me to process. The objective is to write a vb script that would be scheduled to run daily to...
3
by: StGo | last post by:
How can i read/write file's custom attributs(like subject,author...) in C#??? Thanks :))
10
by: Michael Murphy | last post by:
Hi, I have a Windows VB.Net app in which I need to keep files in one folder in sync with files in another folder. I have pasted the code below. Can anyone tell me why I end up with a folder with all...
0
by: Tim Richardson | last post by:
I am attempting to copy some files from one machine to another. I am having difficulty with the File.Exists() in the code below. The program enumerates the files in a directory, checks them...
6
by: TPJ | last post by:
Help me please, because I really don't get it. I think it's some stupid mistake I make, but I just can't find it. I have been thinking about it for three days so far and I still haven't found any...
3
by: Lou | last post by:
Question: I can't seem to get file.exists(filename) to return true when I search using wildcards, and I know there's a file in that dir with that extension. here's the path dim yesno as...
3
by: trint | last post by:
How can I do this with my c# code with my website(because the file is there, but the code doesn't return it)?: if(File.Exists(String.Format("~/images/categories/{0}", sFileName)) return...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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...

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.