or:
using System.IO;
.
.
.
if (File.Exists("c:\\xxx\\qqq
{
MessageBox.Show("It exists!");
}
Main Topics
Browse All TopicsHi,
How do I Check in C# if the file "a.doc" Exist in the folder "c:\xxx\qqq"
thnx
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
You can use Application.StartupPath.
example:
using System.Windows.Forms;
.
.
.
if (File.Exists(Application.S
You just have to be carefull when your application path is root of the drive ( C:\ )
becouse then it will automaticaly contain backslash.
So you could do something like this:
string FullPath;
if (Application.StartupPath.S
FullPath = Application.StartupPath + "filename.txt";
else
FullPath = Application.StartupPath + "\\" + "filename.txt";
if (File.Exists(FullPath)) .......
By default, if you don't specify a path it will look in the same folder your .exe was dumped by the compiler. If you deploy your application this .exe will then be in a folder with all the dependable files you packaged with the install wizard.
If you have your application run at windows startup however I think it will not find the file you are looking for, even if you specify in the code to look in the application folder. I remember that it was trying to read it from the root folder ie C:\. A workaround that I used was to read from the registry the path where the program was installed and use that to get the file I wanted from the folder of the application.
Cheers,
Max.
Business Accounts
Answer for Membership
by: dbrckoviPosted on 2005-11-05 at 04:25:53ID: 15230688
if (System.IO.File.Exists("c: \\xxx\\qqq \\a.doc"))
{
MessageBox.Show("It exists!");
}