Click here to Skip to main content
16,004,806 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
abc = "label_me_red.ico.deploy" is string from StreamReader.ReadLine()

if(File.Exists("label_me_red.ico.deploy"))
{
   // File
}
else
{
// Folder
}

Problem is Its not detecting as File, its going to else condition and displaying as directory.
Posted
Updated 18-Apr-13 5:24am
v2
Comments
joshrduncan2012 18-Apr-13 11:20am    
The way you have it declared the file should be located in the project. If your file is not in the project folder, you should have the full path to it in the File.Exists call.
Friendsaa 18-Apr-13 11:51am    
Thanks, U got me Correctly, when the files are in project, its working.

But i dont want to keep files in my project, so where should i specify full path?

File.Exists(Fullpath)

like this?
joshrduncan2012 18-Apr-13 11:52am    
Yep, that should take care of finding the file for you that you are looking for.
Friendsaa 18-Apr-13 14:47pm    
Even though i mention the full path, Its not reading it as file :(
joshrduncan2012 18-Apr-13 14:50pm    
That means there is something wrong with your path name. Please provide your code as to where you are checking for the file and where your file is located.

It simply means that the file does not exist.

By the way, you should understand this: such naming of a file suggests that it is located in the working directory. This directory can be an executable file directory, but it can be absolutely anything. Do you know that to working directory totally depends on how the user starts the application and can be anywhere, unless your program modifies it.

Please see my past answer for comprehensive information on directories:
How to find my programs directory ( executable directory),
How to find my programs directory (current directory, "special folders").

There are no situations where a hard-coded file path can be useful.

—SA
 
Share this answer
 
if(File.contains(".")
{
//file.
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900