Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6830067
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T22:34:28+00:00 2026-05-26T22:34:28+00:00

i can replace the file name in particular folder , i wrote like this

  • 0

i can replace the file name in particular folder , i wrote like this

FileInfo fsource = new FileInfo(Server.MapPath("~/PurchaseOrder/" + lblhideid.Text));
                        if (fsource.Exists)
                        {
                            string[] file = lblhideid.Text.Split('.');
                            string fName="Z-"+System.DateTime.Now.ToString("MM-dd-yyyy")+"-"+saveConsultantID+"."+file[1];
                            fsource.Name.Replace(lblhideid.Text, fName);

                        }

lblhideid.Text=image.jpeg , so i can replace the my own name like fName , how to replace the name pls give me any suggestion.

Thank u
Hemanth

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T22:34:29+00:00Added an answer on May 26, 2026 at 10:34 pm

    I suspect you want that last line to be:

    fsource.MoveTo(Server.MapPath("~/PuchaseOrder/" + fName));
    

    You current code is only getting the filename as a string and manipulate that string. You want to manipulate the file itself.

    EDIT:

    Are you sure that ~/PurchaseOrder/ exists?

    Try:

    string originalPath = Server.MapPath("~/PurchaseOrder/" + lblhideid.Text);
    
    FileInfo fsource = new FileInfo(originalPath);
    if (fsource.Exists)
    {
         string newName = string.Format("Z-{0:MM-dd-yyyy}-{1}.{2}",
                                        System.DateTime.Now,
                                        saveConsultantID,
                                        fsource.Extension);
    
         string newPath = Path.Combine(fsource.DirectoryName, newName);
         fsource.MoveTo(newPath);                   
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I write a regex which will replace any file name, with it's
How can I replace all line-endings in big file (>100MB)? I have tried to
how can I catch all strings from a native windows .exe file and replace
I'd like to change the file name of the SaveFileDialog in the event handler
After tap some row in UITableView apps goes to new screen. I can replace
I have this function: /*This func runs *.c1 file, and replace every include file
How can I rename each file in folder: pattern is: (first part of file
How can I load a new page in my particular div using ajax in
Is there a way of converting special folder paths to a full file name
am trying to update my database table that looks like this name | file_name

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.