How to create sub folders when creating file?
i am making an application which involves reading chunks of an existing
file and writing them to a new one... now, the problem is that the code i
am currently using does not create subfolders and then file if a full path
is given...
If i give it a path like this: C:\folder1\folder2\file.mp3 it gives an
error because the folders folder1 and 2 does not exist, however, i would
like it to create these subfolders if they do not exist while creating the
file... thanks... here is my code:
Dim bytesRead As Integer
Dim buffer(40096) As Byte
Using inFile As New System.IO.FileStream(arch, IO.FileMode.Open,
IO.FileAccess.Read)
Using outFile As New System.IO.FileStream(path & "\" & f,
IO.FileMode.Create, IO.FileAccess.Write)
inFile.Seek(StartAt, IO.SeekOrigin.Begin)
Do
If astop.Text = 1 = False Then
If CurrentFsize - currtotal < buffer.Length Then
ReDim buffer(CurrentFsize - currtotal)
End If
bytesRead = inFile.Read(buffer, 0, buffer.Length)
If bytesRead > 0 Then
outFile.Write(buffer, 0, bytesRead)
currtotal += bytesRead
End If
Else
Exit Do
Exit Do
End If
Application.DoEvents()
Loop While bytesRead > 0 AndAlso currtotal < CurrentFsize
End Using
End Using
No comments:
Post a Comment