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>
<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?)
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"));
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.