Hello,
with the upload function you can browser your computer to select a file.
afterwards I don’t know how to use this function.
the plan is that users can select a file and upload to the network.
for example \\192.168.0.10\share
a new subfolder needs to be created also per upload
can somebody show me an example for this function.
the function contain a textbox with the path of the file & a button called “upload1” (see attachment)
below the sub,
Private Sub Upload1_Uploaded(sender As Object, e As UploadedEventArgs) Handles Upload1.Uploaded
End Sub
PS: my first thought was to user OpenFileDialog like I’m using for windows forms, but I cannot access my drives.
all is empty, below the code I’ve tested.
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
Dim OpenFileDialog1 As New OpenFileDialog
OpenFileDialog1.InitialDirectory = “C:\Temp”
OpenFileDialog1.ShowDialog()
End Sub
I really need a solution for this, please help me!
thanks in advance.
Hi Bjorn,
It would be something like this (modeled from:https://github.com/iceteagroup/wisej-examples/blob/2.0/UploadFiles/UploadFiles/Window1.cs):
Private Sub upload1_Uploaded(sender As Object, e As UploadedEventArgs) LoadFile(e.Files) For i As Integer = 0 To e.Files.Count - 1 MessageBox.Show("Uploaded " & e.Files(i).FileName) Next End Sub Private Sub LoadFile(files As HttpFileCollection) If files Is Nothing Then Return If files.Count = 0 Then Else Dim fileStream = File.Create(AppDomain.CurrentDomain.BaseDirectory & "\shared\" + files(0).FileName) files(0).InputStream.Seek(0, SeekOrigin.Begin) files(0).InputStream.CopyTo(fileStream) fileStream.Close() End If End Sub
You just need to make sure the “shared” folder exists in the correct directory. Use Directory.CreateDirectory() to create if it doesn’t exist.
To convert C# to VB.NET (maybe not perfect, but definitely very helpful! We’re working on VB samples):
Let me know if this works for you.
Best regards,
Levie
Useful Links:
https://github.com/iceteagroup/wisej-examples/blob/2.0/UploadFiles/UploadFiles/Window1.cs
Hello,
Yes it’s working local I only have to add > Handles Upload1.Uploaded on the first line.
Creating a directory was already working, but I couldn’t upload files 🙂 thank you so much
I will test later on the server (I have to check where I have to create the share folder), but I guess this will not give any issues.
I will test first the convertor, if I need something in the future.
Private Sub upload1_Uploaded(sender As Object, e As UploadedEventArgs) Handles Upload1.Uploaded
LoadFile(e.Files)
For i As Integer = 0 To e.Files.Count – 1
MessageBox.Show(“Uploaded “ & e.Files(i).FileName)
Next
End Sub
Private Sub LoadFile(files As HttpFileCollection)
If files Is Nothing Then Return
If files.Count = 0 Then
Else
Dim fileStream = File.Create(AppDomain.CurrentDomain.BaseDirectory & “\shared\” + files(0).FileName)
files(0).InputStream.Seek(0, SeekOrigin.Begin)
files(0).InputStream.CopyTo(fileStream)
fileStream.Close()
End If
End Sub
Is there a location where can I found vb.net examples for wisej functions?
there are probably nice/new functions that I don’t know or aware of.
Please login first to submit.