Login Register






[HELP] Save File Fialog/Stream Writer filter_list
Author
Message
[HELP] Save File Fialog/Stream Writer #1
Hi, well, I was working on a little generator and I came across a problem,

For some reason, I keep getting "Cannot acess file.php because it is allready used by another process"

Code:
Dim ofd, ofd2 As New SaveFileDialog Dim SWE As Stream ofd.Filter = "php files (*.php)|*.php|All files (*.*)|*.*" ofd.ShowDialog() File.Create(ofd.FileName) SWE = ofd.OpenFile() Using sw As StreamWriter = New StreamWriter(SWE) sw.WriteLine("<?php") sw.WriteLine("$action = $_GET['action'];") sw.WriteLine("$data = $_GET['data'];") sw.WriteLine("if ($action == " & Chr(34) & "delete" & Chr(34) & "){") sw.WriteLine("unlink(" & Chr(34) & "log.txt" & Chr(34) & ");") sw.WriteLine("$new = fopen(" & Chr(34) & "log.txt" & Chr(34) & ", 'a');") sw.WriteLine("fclose($new);") sw.WriteLine("}") sw.WriteLine("if ($action == " & Chr(34) & "write" & Chr(34) & "){") sw.WriteLine("$open = fopen(" & Chr(34) & "log.txt" & Chr(34) & ", 'a');") sw.WriteLine("fwrite($open, $data." & Chr(34) & "\n" & Chr(34) & ");") sw.WriteLine("fclose($open);") sw.WriteLine("}") sw.WriteLine("?>") sw.Close() End Using

thanks for any help Smile
Staff will never ever ask you for your personal information.
We know everything about you anyway.

Reply

RE: [HELP] Save File Fialog/Stream Writer #2
Just remove the File.Create.

Here is the whole code:
Code:
Dim saveDialog As New SaveFileDialog Dim aStream As IO.Stream saveDialog.Filter = "php files (*.php)|*.php|All files (*.*)|*.*" If saveDialog.ShowDialog = 1 Then aStream = saveDialog.OpenFile() Using sw As IO.StreamWriter = New IO.StreamWriter(aStream) sw.WriteLine("<?php") sw.WriteLine("$action = $_GET['action'];") sw.WriteLine("$data = $_GET['data'];") sw.WriteLine("if ($action == """"delete""""){") sw.WriteLine("unlink(""""log.txt"""");") sw.WriteLine("$new = fopen(""""log.txt"""", 'a');") sw.WriteLine("fclose($new);") sw.WriteLine("}") sw.WriteLine("if ($action == """"write""""){") sw.WriteLine("$open = fopen(""""log.txt"""", 'a');") sw.WriteLine("fwrite($open, $data.""""\n"""");") sw.WriteLine("fclose($open);") sw.WriteLine("}") sw.WriteLine("?>") sw.Close() End Using End If
[Image: rytwG00.png]
Redcat Revolution!

Reply

RE: [HELP] Save File Fialog/Stream Writer #3
(02-23-2011, 07:23 AM)Coder-san Wrote: Just remove the File.Create.

Here is the whole code:
Code:
Dim saveDialog As New SaveFileDialog Dim aStream As IO.Stream saveDialog.Filter = "php files (*.php)|*.php|All files (*.*)|*.*" If saveDialog.ShowDialog = 1 Then aStream = saveDialog.OpenFile() Using sw As IO.StreamWriter = New IO.StreamWriter(aStream) sw.WriteLine("<?php") sw.WriteLine("$action = $_GET['action'];") sw.WriteLine("$data = $_GET['data'];") sw.WriteLine("if ($action == """"delete""""){") sw.WriteLine("unlink(""""log.txt"""");") sw.WriteLine("$new = fopen(""""log.txt"""", 'a');") sw.WriteLine("fclose($new);") sw.WriteLine("}") sw.WriteLine("if ($action == """"write""""){") sw.WriteLine("$open = fopen(""""log.txt"""", 'a');") sw.WriteLine("fwrite($open, $data.""""\n"""");") sw.WriteLine("fclose($open);") sw.WriteLine("}") sw.WriteLine("?>") sw.Close() End Using End If

Thanks Smile
And, the """"write"""", how does that work? Smile thanks Smile
Staff will never ever ask you for your personal information.
We know everything about you anyway.

Reply

RE: [HELP] Save File Fialog/Stream Writer #4
Inside double-quotes, double-quotes will appear when there are 4 continuous double-quotes.
For opening and closing, you need three of them.
[Image: rytwG00.png]
Redcat Revolution!

Reply

RE: [HELP] Save File Fialog/Stream Writer #5
(02-23-2011, 09:44 AM)Coder-san Wrote: Inside double-quotes, double-quotes will appear when there are 4 continuous double-quotes.
For opening and closing, you need three of them.

oh cool Smile yay no more & Chr(34 or w/e its the number) &.... Smile
Thanks Smile
Staff will never ever ask you for your personal information.
We know everything about you anyway.

Reply