Replace FileName with String

This is a discussion on Replace FileName with String within the DOTNET forums in Framework and Interface Programming category; Hello, I have a path as follows: "Assets/Documents/Portfolio.pdf" I want to replace the file name, "Portfolio", by the content of the string NewName. How can I do this? Thanks, Miguel...

Go Back   Application Development Forum > Framework and Interface Programming > DOTNET

Object Mix

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #1  
Old 09-08-2008, 08:49 AM
shapper
Guest
 
Default Replace FileName with String

Hello,

I have a path as follows:

"Assets/Documents/Portfolio.pdf"

I want to replace the file name, "Portfolio", by the content of the
string NewName.

How can I do this?

Thanks,
Miguel
Reply With Quote
  #2  
Old 09-08-2008, 09:19 AM
Mark Rae [MVP]
Guest
 
Default Re: Replace FileName with String

"shapper" <mdmoura@gmail.com> wrote in message
news:1bb5f531-7b37-4923-958b-f1f3bd02b6e0@x35g2000hsb.googlegroups.com...

> I have a path as follows:
>
> "Assets/Documents/Portfolio.pdf"
>
> I want to replace the file name, "Portfolio", by the content of the
> string NewName.


string strRawPath = "Assets/Documents/Portfolio.pdf";
string strNewName = "Shapper";
string strNewPath =
strRawPath.Replace(Path.GetFileNameWithoutExtensio n(strRawPath),
strNewName);


--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Reply With Quote
Reply


Thread Tools
Display Modes


All times are GMT -5. The time now is 10:03 AM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
vB Ad Management by =RedTyger=

In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.