dimanche 10 mai 2015

How do I slim down this vb.net code for creating files

Sub file_createAA()
 Dim filepath As String = System.IO.Path.Combine(My.Computer.FileSystem.SpecialDirectories.MyDocuments, "calculator\addition\attack\1.txt")
 If Not System.IO.File.Exists(filepath) Then
    System.IO.File.Create(filepath).Dispose()
 End If
End Sub

This code is repeated 64 times, each time creating a new file. The code below, also repeated 64 times with each slightly varied, also makes the folder paths required. Is there any way to slim this down as each one is rather long.

My.Computer.FileSystem.CreateDirectory(System.IO.Path.Combine(My.Computer.FileSystem.SpecialDirectories.MyDocuments, "calculator\addition\attack"))

Aucun commentaire:

Enregistrer un commentaire