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

  • Home
  • SEARCH
  • 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 6849583
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:00:34+00:00 2026-05-27T01:00:34+00:00

How can I rename the file to a timestamp or random unique number before

  • 0

How can I rename the file to a timestamp or random unique number before it is actually ftped to the server?

example: if i select C:\taco.pdf ….. 1321981871.pdf is actually what would be ftp’d to the server.

FileInfo toUpload = new FileInfo(this.txtFile.Text);

 FtpWebRequest request =
            (FtpWebRequest)WebRequest.Create(
            "ftp://192.168.0.186" + "/" + toUpload.Name
            );

 request.Method = WebRequestMethods.Ftp.UploadFile;

request.Credentials =
            new NetworkCredential("myuser","mypassword");

Stream ftpStream = request.GetRequestStream();
        FileStream file = File.OpenRead(this.txtFile.Text);

 int length = 1024;
        byte[] buffer = new byte[length];
        int bytesRead = 0;


        do
        {
            bytesRead = file.Read(buffer, 0, length);
            ftpStream.Write(buffer, 0, bytesRead);
        }
        while (bytesRead != 0);

 file.Close();
        ftpStream.Close();
  • 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-27T01:00:35+00:00Added an answer on May 27, 2026 at 1:00 am

    If you just want the file uploaded with a different name without renaming it locally, couldn’t you just change

     FtpWebRequest request = 
                (FtpWebRequest)WebRequest.Create( 
                "ftp://192.168.0.186" + "/" + toUpload.Name 
                ); 
    

    to

     FtpWebRequest request = 
                (FtpWebRequest)WebRequest.Create( 
                "ftp://192.168.0.186/whatever file name you want"); 
    

    ?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Under linux, you can rename a file with overwrite. For example, rename -f file_a
I remember in SVN, I can rename a file from foo.txt to foo2.txt and
I want to copy a file from \\Server\SharedFolder\NameOfFile.txt to \\Server2\SecondSharedFolder\NameOfFile - 1-10-2012.txt I can
How can I rename a file in linux to strip out certain characters from
How can I rename 1..n file with ANT? I would like to rename any
How can I rename each file in folder: pattern is: (first part of file
The title is self-explanatory, I want to know how I can rename a file
How do I use File::Copy to rename a file extension? So far, I can
I know that I can rename my webapp (or it's WAR file) to ROOT
Can I safely rename an aif file to caf and use that with Core

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.