Path

  • Thread starter Thread starter shapper
  • Start date Start date
S

shapper

Hello,

I am using Server.MapPath("~/App_Data/") to get the absolute path.

I need to create the full path of a file. So I can use:

String.Concat(Server.MapPath("~/App_Data/"), filename);

But I get an error if I pass just "~/App_Data" ... Ok I can solve that
easy.

But I think there is a .NET method for this ... I have that idea but I
can't find it.

Do you know which one it is?

Thanks,
Miguel
 
Hello,

I am using Server.MapPath("~/App_Data/") to get the absolute path.

I need to create the full path of a file. So I can use:

String.Concat(Server.MapPath("~/App_Data/"), filename);

But I get an error if I pass just "~/App_Data" ... Ok I can solve that
easy.

But I think there is a .NET method for this ... I have that idea but I
can't find it.

Do you know which one it is?

Thanks,
Miguel

Sorry, I finally found it. Is System.IO.Path.Combine.

Thanks,
Miguel
 
shapper said:
Hello,

I am using Server.MapPath("~/App_Data/") to get the absolute path.

I need to create the full path of a file. So I can use:

String.Concat(Server.MapPath("~/App_Data/"), filename);

But I get an error if I pass just "~/App_Data" ... Ok I can solve that
easy.

But I think there is a .NET method for this ... I have that idea but I
can't find it.

Do you know which one it is?

If you use the System.IO.Path class, you can combine paths without as
much fiddling in your own code. It will insert directory separator
characters as necessary.

Pete
 
Back
Top