我正在制作一个打开文件的程序,保存后,程序会将其保存到新文件夹中,原始文件保持不变。
但是,我尝试使用的代码都没有用。
如何创建一个新文件夹,该文件夹将进入已加载文件的FilePath?
如何保存到该文件夹?
我试过这个并收到错误..“找不到或无法访问”
Private Sub SaveChangesToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveChangesToolStripMenuItem1.Click
newFilePath = FilePath + "\" + newFolderName + "Folder"
Try
Dim Writer As New PackageIO.Writer(newFilePath = orgFilePath + "\" + newFolderName, "Folder 1", PackageIO.Endian.Big)
System.IO.Directory.CreateDirectory(newFilePath)
我在这里尝试了这个代码,它似乎最接近工作,但是说文件路径无效;我假设是因为它包括他们选择的文件,而不仅仅是所涉及的文件夹。
Private Sub SaveChangesToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveChangesToolStripMenuItem1.Click
newFilePath = FilePath + "\" + newFolderName + "Folder"
Try
Dim Writer As New PackageIO.Writer(newFilePath, PackageIO.Endian.Big)
System.IO.Directory.CreateDirectory(newFilePath)
答案 0 :(得分:0)
尝试以下几点:
Dim orgFilePath as String
Dim newFolderName as String
Dim newFilePath as String
'you will need to set the path of the original file and give a name for the new folder
newFilePath = orgFilePath + "\" + newFolderName
'creates new directory (folder)
System.IO.Directory.CreateDirectory(newFilePath)
'then put the code to save your file to the newFilePath variable
希望有所帮助