views:

117

answers:

1

Okay so the following line returns null because its path cannot be found:

System.IO.FileInfo fi = di.GetFiles()[position];

What I am currently doing is:

<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<ctl:Gallery runat="server" ID="Gallery1" FolderUrl="~/images/1/" Size="100" />

When this is invoked System.IO.FileInfo fi = di.GetFiles()[position]; it has the value similar to this:

C:\Users\SomeUsername\Desktop\Tiamo\(S(mr1h0l55ycuixfbtqxbmttek))\images\1

Any idea how I can return the virtual path without actually having the session key in there? Thank you in advanced for any help you may give :) much appreciated.

+1  A: 

If I understand your question correctly, this should help you:

var path = Path.GetFullPath(HttpContext.Request.MapPath(HttpContext.Request.ApplicationPath)
var listOfFiles = Directory.GetFiles(path);
Jarek
FolderUrl="<%=Context.Request.ApplicationPath;%>/images/1" Ive been told this would also work but it returns illegal characters exception
Anicho