?
Solved

File not found error - for any file I try to copy or read

Posted on 2003-03-14
4
Medium Priority
?
181 Views
Last Modified: 2010-04-15
Help! I get a file not found error regardless of what file I look for or what method I use (copy, read, etc.)! I am running the following code and have tried to reduce to the simplest possible case
(root directory, short file name). I am working on my local pc and the file is on the same pc. I've included the escape character. But whatever I try, I get the error:

'Could not find file "c:\test.txt" '


using System;
using System.IO;


namespace ValidateGPCFile
{
     /// <summary>
     /// Summary description for clsFileManipulation.
     /// </summary>
     public class clsFileManipulation
     {     public string Message;

          // Default constructor:
          public clsFileManipulation()
          {
                         }

          // copy method:
          public void CopyFile()
          {
                         
               try
               {
                    //next line always produces 'cannot find file "c:\test.txt" error
                    File.Copy("c:\\test.txt", "c:\\test1.txt", true);                                            Message = "Valid";
               }
               catch (FileNotFoundException ex)
               {  
                                //the code always goes here
                    Message = "Invalid. " + ex.Message;
               }          }
     }

     
}
0
Comment
Question by:dennis_skidmore
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 2

Expert Comment

by:AndrewK
ID: 8138885
Complete shot in the dark - have you tried using the string literal @ ?

File.Copy(@"c:\test.txt", @"c:\test1.txt", true);

0
 
LVL 1

Accepted Solution

by:
zubok32 earned 400 total points
ID: 8172647
Hi. Check if your application has access permissions to this file.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question