Click here to Skip to main content
16,004,836 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
how can we find/search a file at run time from our application with C#??

in my application number of pdf file.
i want to search a particular pdf file on the selection of drop down list????
Posted
Comments
Sergey Alexandrovich Kryukov 10-Nov-11 3:15am    
Just by file name (mask)? -- this is easy. Or using content of the file, with PDFs?
--SA
soniya sangal 10-Nov-11 3:41am    
i am not getting
Sergey Alexandrovich Kryukov 11-Nov-11 0:40am    
Exactly, you are not getting...
If you not explain what exactly do you want, nobody will help you.
--SA

1 solution

C#
private bool CheckFileExistance(string filePath)
{
    // it will return true if file is available or false if file is not available
    //use this if your file path will like this.... C:\test.txt
    //filePath = "C:\PDF\test.pdf"   then use this....
    return System.IO.File.Exists(filePath); //path like C:\test.txt
    ///////////////////OR////////////////////////
    //use this if your path is like ~/PDF/test.pdf..
    //so if your pdf files where store in pdf directory then use this method for getting path
    //Server.MapPath("~/PDF/test.pdf")  
    //filePath =   "~/PDF/test.pdf"        then use this....
    return System.IO.File.Exists(Server.MapPath(filePath));
}


use this method for checking your file for existence...
 
Share this answer
 
v2
Comments
soniya sangal 10-Nov-11 4:44am    
after that what have to do
Tejas Vaishnav 10-Nov-11 7:15am    
what you want to do is depends on you...
you can ask for searching a file then i will write a method for you that will find the file from your file path if it will exits or not,, if it will exist this will return true or else false...

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