Click here to Skip to main content
15,896,063 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi
How to get file name with or without its extension form root folder.I am deploy website in web server,inside root folder i have temp folder for saving file while download form sql server as bytes.

Below is deploy websit in server machine and it temp folders
sampleWeb is website root folder and Temp is temporary folder and it sub folder as follow

C:\inetpub\wwwroot\Sampleweb\Temp\1026\Vw\Memo

Below if file available in Memo more than one files

C:\inetpub\wwwroot\Sampleweb\Temp\1026\Vw\Memo\Memo.pdf
C:\inetpub\wwwroot\Sampleweb\Temp\1026\Vw\Memo\Memo.txt
C:\inetpub\wwwroot\Sampleweb\Temp\1026\Vw\Memo\Memo.xls


Actually i know upto "C:\inetpub\wwwroot\Sampleweb\Temp\1026\Vw\Memo",my need is,i will pass C:\inetpub\wwwroot\Sampleweb\Temp\1026\Vw\Memo path and need to get any file(with or without extension) inside Memo folder.

What i am try in this

VB
path="C:\inetpub\wwwroot\Sampleweb\Temp\1026\Vw\Memo"
If File.Exists(fpath) Then '--------here i get error
Dim filname As String() = Directory.GetFiles(fpath)
End If


If i pass path with file name it work like this
VB
path="C:\inetpub\wwwroot\Sampleweb\Temp\1026\Vw\Memo\Memo.pdf"


But i don't the file name ,so only pass folder path need to get file name.


Regards
Aravind
Posted

1 solution

Try:
VB
Dim root As String = Server.MapPath("~\Temp\1026\Vw\Memo")
If Directory.Exists(root) Then
    Dim files As String() = Directory.GetFiles(root)
End If
 
Share this answer
 
Comments
Maciej Los 8-Jul-14 14:05pm    
Small change, big difference!

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