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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T06:21:23+00:00 2026-05-24T06:21:23+00:00

I Have a folder in this path C:\Users\XXX\Desktop\Original\XXX\bin\Debug\Backup And when I save my project

  • 0

I Have a folder in this path
C:\Users\XXX\Desktop\Original\XXX\bin\Debug\Backup

And when I save my project with “XXX” name the same time I need to change the Backup Folder using that save filedialog name and it shouldn’t overwrite it.

Can anyone suggest me how to do this:

Here is the code how I am doing it and it didn’t work for me:

Private Sub SaveProject_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveProject.Click

    Using sfdlg As New Windows.Forms.SaveFileDialog
        sfdlg.OverwritePrompt = True
        sfdlg.InitialDirectory = "C:\"
        sfdlg.FileName = "Untitled"
        sfdlg.DefaultExt = "amk"
        sfdlg.Filter = "AquaMark Project|*.amk"
        If sfdlg.ShowDialog = Windows.Forms.DialogResult.OK Then


            Dim SaveData As New gCanvasData

            With SaveData
                frmDisplay.GCanvas1.UnselectCurrentAnotate()
                .gAnnotates = frmDisplay.GCanvas1.gAnnotates
                .Image = frmDisplay.GCanvas1.Image

            End With

            Using objStreamWriter As New StreamWriter(sfdlg.FileName)
                Dim x As New XmlSerializer(GetType(gCanvasData))
                x.Serialize(objStreamWriter, SaveData)
                objStreamWriter.Close()
            End Using
        End If
        sfdlg.Dispose()
        System.IO.Path.GetFileNameWithoutExtension(sfdlg.FileName)
        IO.Directory.Move(Application.StartupPath + "\Backup\", Application.StartupPath + "\Backup\" & System.IO.Path.GetFileNameWithoutExtension(sfdlg.FileName))
    End Using
End Sub

But can anyone clearly mention me how to do it?

  • 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-24T06:21:24+00:00Added an answer on May 24, 2026 at 6:21 am

    Based on the error, you most likely won’t be able to save the file and change the backup folder name through the same SaveFileDialog.

    Break it into two steps:

    1. Save the file through the SaveFileDialog. Be sure to capture the filename from SaveFileDialog so you can use it in step 2, as it may be out of scope after you close the SaveFileDialog window.
    2. Rename the backup folder using the command above, but after you’ve closed the SaveFileDialog so the handle is released.

    EDIT

    As I noted in step 1, you need to save the filename somewhere so you can use it in step 2.

    Private Sub SaveProject_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveProject.Click
    
       ' Set up a variable to hold the filenam
       Dim fileName As String
    
        Using sfdlg As New Windows.Forms.SaveFileDialog
            sfdlg.OverwritePrompt = True
            sfdlg.InitialDirectory = "C:\"         
            sfdlg.FileName = "Untitled"         
            sfdlg.DefaultExt = "amk"         
            sfdlg.Filter = "AquaMark Project|*.amk"         
    
            If sfdlg.ShowDialog = Windows.Forms.DialogResult.OK Then
                Dim SaveData As New gCanvasData 
    
                ' Store the filename from the SaveFileDialog
                fileName = sfdlg.FileName             
    
                With SaveData                 
                    frmDisplay.GCanvas1.UnselectCurrentAnotate()                 
                    .gAnnotates = frmDisplay.GCanvas1.gAnnotates                 
                    .Image = frmDisplay.GCanvas1.Image              
                End With              
    
                Using objStreamWriter As New StreamWriter(sfdlg.FileName)                 
                    Dim x As New XmlSerializer(GetType(gCanvasData)) 
                    x.Serialize(objStreamWriter, SaveData)     
                    objStreamWriter.Close()             
                End Using         
            End If         
    
            'Calling Dispose is redundant since sfdlg was in a Using block
            'sfdlg.Dispose()         
            ' You can't use sfdlg.FileName here as the object is out of scope
            'System.IO.Path.GetFileNameWithoutExtension(sfdlg.FileName)
            'IO.Directory.Move(Application.StartupPath + "\Backup\", Application.StartupPath + "\Backup\" & System.IO.Path.GetFileNameWithoutExtension(sfdlg.FileName)) 
             ' Use the value in fileName from above
             System.IO.Directory.Move(Application.StartupPath + "\Backup\", Application.StartupPath + "\Backup\" & System.IO.Path.GetFileNameWithoutExtension(fileName))    
        End Using 
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If I have a folder structure that looks like this: / /bin/myComponent.cfc /reports/index.cfm How
I have this code: class DocumentIdentifier attr_reader :folder, :name def initialize( folder, name )
I have folder home/admin. In this folder there is index.php. When i access to
I have a folder named repository in my admin folders. This folder holds 2
I have a folder C:\Images which has a some images. This folder is not
I have a folder structure like this: /some_folder /tmp /tmp/foo /tmp/foo/fu * /tmp/bar /tmp/bar/bah
I have a folder structure like this: /articles .index.php .second.php .third.php .fourth.php If I'm
Say I have this url: http://site.example/dir/ In this folder I have these files: test.ascx.cs
I have some folder with different files. I want to use something like this:
I am having a hard time on this one, I have a folder over

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.