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 9086997
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T21:36:58+00:00 2026-06-16T21:36:58+00:00

just looking for some help on this. I’ve tried a few different things and

  • 0

just looking for some help on this. I’ve tried a few different things and I’m stumped. I’m trying to take a check if a file exists in a directory, and if it does, then I want to rename add - Copy to the file name. Then it should check again if there is a conflict, and if there isn’t it should move the file. Sounds simple enough, but it isn’t working at all. Since I can’t convert from String to DirectoryInfo, I have to declare multiple variables, and it just doesn’t feel right. What can I do to fix this?

Dim fileExt As String = ""

Dim oldFileName As String = file.FullName
Dim newFileName As String = oldFileName
Dim newFileLocation = Environment.GetSpecialFolder(Environment.SpecialFolder.MyPictures) + "\" + file.Name

While FileIO.FileSystem.FileExists(newFileLocation) 'While File exists in new directory
    'Add copy to filename
    fileExt = fileType.Replace("*", "")
    newFileName = newFileName.Remove(newFileName.LastIndexOf("."), (newFileName.Length - newFileName.LastIndexOf(".")))
    newFileName += " - Copy"
    newFileName += fileExt

    'Rename file
    FileSystem.Rename(oldFileName, newFileName)

    'Declare a new DirInf variable because I can't use a string to set one
    Dim newFile As New DirectoryInfo(newFileName)

    'Move the new file to 
    newFile.MoveTo("C:\Users\" + Environ("USERNAME") + "\Pictures\")
    ProgressBar.Value += 1
End While
  • 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-06-16T21:37:00+00:00Added an answer on June 16, 2026 at 9:37 pm

    You’re looking for File.Move(), which takes two strings.

    Also, "C:\Users\" + Environ("USERNAME") + "\Pictures\" is very wrong; many users do not have C: drives.
    You should call Environment.GetSpecialFolder(Environment.SpecialFolder.MyPictures)

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

Sidebar

Related Questions

I have posted this a few times looking for some help, I cant seem
Sorry if this is something stupid but just looking for some genuine help. Struggling
I am looking for some help. I have found this script that sort of
I'm looking for some help converting this from prototype to jQuery. I'm doing some
I am looking for some help with grep, or grep like tools. This includes
Looking for some help with my SQL query. I am trying to find a
I'm looking for some help on how to realize something like this: img http://img1.firenex.net/ssFan8c00f9Ul1QnQzGt.png
I am looking for some help with regex. I have this piece of code:
Sorry if this sounds simple, but I'm looking for some help to improve my
HI I am looking for some help I just can't seem to get my

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.