help me!!! Could not find a part of the path "D:\".
-
i use following code to create a folder (.net 1.1)
if ( Directory.Exists(Server.MapPath("~/temp") +"/"+ SID) )//Request.PhysicalApplicationPath +
//"temp\\" + SID) )
{
lbl_event.Text=ss;
Directory.Delete( Server.MapPath("~/temp") +"/"+ SID, true );
}
Directory.CreateDirectory(Server.MapPath("~/temp") +"/"+ SID );and following error appear "Could not find a part of the path "D:\"." you can see the error with its details http://kmrt.ir/Welcome.aspx[^] it is not for permission! anyone know how could i solve it?!! please help me
-
i use following code to create a folder (.net 1.1)
if ( Directory.Exists(Server.MapPath("~/temp") +"/"+ SID) )//Request.PhysicalApplicationPath +
//"temp\\" + SID) )
{
lbl_event.Text=ss;
Directory.Delete( Server.MapPath("~/temp") +"/"+ SID, true );
}
Directory.CreateDirectory(Server.MapPath("~/temp") +"/"+ SID );and following error appear "Could not find a part of the path "D:\"." you can see the error with its details http://kmrt.ir/Welcome.aspx[^] it is not for permission! anyone know how could i solve it?!! please help me
Nafiseh Salmani wrote:
Server.MapPath("~/temp") +"/"+ SID
What kind of system are you using? That would work on a *nix system, as that uses "/" as file path separator, but it would not work on a Windows system, as that uses "\" as file path separator. You should use the Path.Combine method to form the path, that way it will work regardlesss of what file path separator the system uses:
Path.Combine(Server.MapPath("~/temp"), SID)
Despite everything, the person most likely to be fooling you next is yourself.
-
Nafiseh Salmani wrote:
Server.MapPath("~/temp") +"/"+ SID
What kind of system are you using? That would work on a *nix system, as that uses "/" as file path separator, but it would not work on a Windows system, as that uses "\" as file path separator. You should use the Path.Combine method to form the path, that way it will work regardlesss of what file path separator the system uses:
Path.Combine(Server.MapPath("~/temp"), SID)
Despite everything, the person most likely to be fooling you next is yourself.
i checked
Server.MapPath("~/temp") +"/"+ SID
. it works . just when i use
Directory.Delete
or
Directory.CreateDirectory
it takes Error. i set the permission also! How could I solve it?
-
i use following code to create a folder (.net 1.1)
if ( Directory.Exists(Server.MapPath("~/temp") +"/"+ SID) )//Request.PhysicalApplicationPath +
//"temp\\" + SID) )
{
lbl_event.Text=ss;
Directory.Delete( Server.MapPath("~/temp") +"/"+ SID, true );
}
Directory.CreateDirectory(Server.MapPath("~/temp") +"/"+ SID );and following error appear "Could not find a part of the path "D:\"." you can see the error with its details http://kmrt.ir/Welcome.aspx[^] it is not for permission! anyone know how could i solve it?!! please help me
Did you consider using the debugger to see what the path is it's trying to write to ?
Christian Graus No longer a Microsoft MVP, but still happy to answer your questions.
-
Did you consider using the debugger to see what the path is it's trying to write to ?
Christian Graus No longer a Microsoft MVP, but still happy to answer your questions.
I cant use it! because it happen when i upload it not at localhost :doh:
-
I cant use it! because it happen when i upload it not at localhost :doh:
Then write a page which works out the path and writes it to the page, so you can see what you're dealing with.
Christian Graus No longer a Microsoft MVP, but still happy to answer your questions.
-
i checked
Server.MapPath("~/temp") +"/"+ SID
. it works . just when i use
Directory.Delete
or
Directory.CreateDirectory
it takes Error. i set the permission also! How could I solve it?
Nafiseh Salmani wrote:
i checked Server.MapPath("~/temp") +"/"+ SID . it works .
In what sense do you mean that it works? If you are using it as a path in a Windows system, it's not correct. It might work eventhough in some situations, but fail in others.
Nafiseh Salmani wrote:
How could I solve it?
Eh? I already told you. Gave you the code for it and everything.
Despite everything, the person most likely to be fooling you next is yourself.
-
i use following code to create a folder (.net 1.1)
if ( Directory.Exists(Server.MapPath("~/temp") +"/"+ SID) )//Request.PhysicalApplicationPath +
//"temp\\" + SID) )
{
lbl_event.Text=ss;
Directory.Delete( Server.MapPath("~/temp") +"/"+ SID, true );
}
Directory.CreateDirectory(Server.MapPath("~/temp") +"/"+ SID );and following error appear "Could not find a part of the path "D:\"." you can see the error with its details http://kmrt.ir/Welcome.aspx[^] it is not for permission! anyone know how could i solve it?!! please help me
You had better debug it,or create a new file to debug filepath validation.Certainly,you also use following: Directory.Delete(Server.MapPath(@"./temp")+"//"+sid,true); or Directory.Delete(Server.MapPath(".//temp")+"//"+sid,true); Ple notice "/" in limit!
studing is processing in this life.