sd41
-
Total Posts
:
3
- Scores: 0
-
Reward points
:
0
- Joined: 7/17/2008
-
Status: offline
|
try to delete a file only when it exists. but this script give me error
Thursday, July 24, 2008 4:58 AM
( permalink)
Imports System Imports System.IO Imports System.Text Public Class Test Public Shared Sub Main() Dim path As String = "c:\temp\MyTest.txt" Try Dim sw As StreamWriter = File.CreateText(path) sw.Close() Dim path2 As String = path + "temp" ' Ensure that the target does not exist. File.Delete(path2) ' Copy the file. File.Copy(path, path2) Console.WriteLine("{0} was copied to {1}.", path, path2) ' Delete the newly created file. File.Delete(path2) Console.WriteLine("{0} was successfully deleted.", path2) Catch e As Exception Console.WriteLine("The process failed: {0}", e.ToString()) End Try End Sub End Class line 5 char 8 error: expected identifier code: 800a03f2 thanks,
|
|
|
|
dm_4ever
-
Total Posts
:
3687
- Scores: 82
-
Reward points
:
0
- Joined: 6/29/2006
- Location: Orange County, California
-
Status: offline
|
RE: try to delete a file only when it exists. but this script give me error
Thursday, July 24, 2008 5:28 AM
( permalink)
I tried your code....are you sure this file exists "c:\temp\MyTest.txt"
|
|
|
|