2005-01-31 Zoltan Varga <vargaz@freemail.hu>
[mono.git] / mcs / class / Microsoft.VisualBasic / Test / standalone / 6614.vb
1   '\r
2   ' Copyright (c) 2002-2003 Mainsoft Corporation.\r
3   '\r
4   ' Permission is hereby granted, free of charge, to any person obtaining a\r
5   ' copy of this software and associated documentation files (the "Software"),\r
6   ' to deal in the Software without restriction, including without limitation\r
7   ' the rights to use, copy, modify, merge, publish, distribute, sublicense,\r
8   ' and/or sell copies of the Software, and to permit persons to whom the\r
9   ' Software is furnished to do so, subject to the following conditions:\r
10   ' \r
11   ' The above copyright notice and this permission notice shall be included in\r
12   ' all copies or substantial portions of the Software.\r
13   ' \r
14   ' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
15   ' IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r
16   ' FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r
17   ' AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r
18   ' LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\r
19   ' FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\r
20   ' DEALINGS IN THE SOFTWARE.\r
21   '
22
23
24 Imports System\r
25 Imports System.IO\r
26 Imports Microsoft.VisualBasic\r
27 \r
28 Public Class TestClass\r
29     Public Function Test() As String\r
30         Dim fn1 As Integer\r
31         Dim fn2 As Integer\r
32         Dim w As Long\r
33 \r
34         '// make sure all files are closed\r
35         Microsoft.VisualBasic.FileSystem.Reset()\r
36 \r
37         '// create a file for the test\r
38         Dim SourceFile As String\r
39         Dim DestinationFile As String\r
40         SourceFile = System.IO.Directory.GetCurrentDirectory() + "\data\textfile.txt"\r
41         DestinationFile = System.IO.Directory.GetCurrentDirectory() + "\data\6614.txt"\r
42         Dim f As System.IO.FileInfo = New System.IO.FileInfo(DestinationFile)\r
43         If (f.Exists) Then\r
44             Kill(DestinationFile)\r
45         End If\r
46         FileCopy(SourceFile, DestinationFile)\r
47 \r
48 \r
49         Dim caughtException As Boolean\r
50 \r
51         '// file number does not exist.\r        caughtException = False\r        Try\r            fn1 = FreeFile()\r
52             FileOpen(fn1, System.IO.Directory.GetCurrentDirectory() + "\data\6614.txt", OpenMode.Input)\r
53             w = LOF(256)\r
54         Catch e As IOException\r            FileClose(fn1)\r            If Err.Number = 52 Then\r                caughtException = True\r            End If\r        End Try\r        If caughtException = False Then Return "sub test 1 failed"\r\r
55 \r
56         '// File mode is invalid\r        'caughtException = False\r        'Try\r        '    'left as an Excerisize to the user ;)\r        'Catch e As IOException\r        '   If Err.Number = 54 Then\r        '       caughtException = True\r        '   End If\r        'End Try\r        'If caughtException = False Then Return "sub test 2 failed"\r\r\r
57         Return "success"\r
58     End Function\r
59 End Class\r