Save File

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • OuTCasT
    Contributor
    • Jan 2008
    • 374

    Save File

    Hi
    So i want a user to be able to create a new folder or choose folder where the document lies(pdf, .doc etc)

    then save the document to another folder of the users choice.

    So in essence when creating a new record in the database, I would like the user permission to link a document to that entry, so once the entry is created they can link a file to it, under a folder which location is also saved in the database.

    So i use the openfiledialog to find the specified file the user wants to save in this NEW folder the user is going to create. Or i will create dynamically with same ID as new entry in database so can be referenced.

    how do i copy the file from its location to the new location.
    making use of a savedialog but duno the code needed to save it.
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    The FileSystemObjec t object will let you manage files.

    Comment

    • OuTCasT
      Contributor
      • Jan 2008
      • 374

      #3
      Hey Rabbit

      Thanks I ended up using this code
      Code:
       'Open File Location
              OpenFileDialog1.ShowDialog()
              lblLocation.Text = OpenFileDialog1.FileName
              'Set Save location
              SaveFileDialog1.FileName = OpenFileDialog1.FileName
              'Set file filters
              SaveFileDialog1.Filter = "PDF(*.pdf)|*.pdf|Word Document old(*.doc)|*.doc|Excel(*.xls)|*.xls|All Files(*.*)|*.*"
              If SaveFileDialog1.ShowDialog() = DialogResult.OK Then
                  'Get file location and move to destination folder\
                  fso = CreateObject("Scripting.FileSystemObject")
                  f1 = fso.GetFile(lblLocation.Text)
                  f1.move(SaveFileDialog1.FileName)
              End If

      Comment

      Working...