Reputation: 5010
When I try to run .aspx page with next code:
System.IO.File.Delete("~/img/afisha/" + fileName);
it writes a message: "Could not find a part of the path 'C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\~\img\afisha\brs_01.jpg'." But I need to use relative path.
ps. the same thing happens with the connection string: <add name="accessConStr" connectionString="Provider=Microsoft.ACE.OLEDB.12.0; data source=ExpertBase.mdb; Persist Security Info=False;" providerName="System.Data.OleDb"></add>
Any ideas? (and will it work on the server properlly?)
Upvotes: 1
Views: 978
Reputation: 63552
Try Server.MapPath()
System.IO.File.Delete(Server.MapPath("~/img/afisha/" + fileName));
for the connection string you can try using a variable string instead
internal readonly string CONNECTION_STRING = "Provider=Microsoft.ACE.OLEDB.12.0; data source={0}; Persist Security Info=False;"
internal static string ConnectionString
{
get
{
return string.Format(CONNECTION_STRING,
Server.MapPath("~/ExpertBase.mdb"));
}
}
Upvotes: 3