added samples
[windows-sources.git] / sdk / samples / FrameworkSamples / CLR / FileDemo / vb / filedemo / general.vb
blob9150e3faab0527ffebcb2046f253a6dd71cf6420
1 '-----------------------------------------------------------------------
2 ' This file is part of the Microsoft .NET SDK Code Samples.
3 '
4 ' Copyright (C) Microsoft Corporation. All rights reserved.
5 '
6 'This source code is intended only as a supplement to Microsoft
7 'Development Tools and/or on-line documentation. See these other
8 'materials for detailed information regarding Microsoft code samples.
9 '
10 'THIS CODE AND INFORMATION ARE PROVIDED AS IS WITHOUT WARRANTY OF ANY
11 'KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
12 'IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
13 'PARTICULAR PURPOSE.
14 '-----------------------------------------------------------------------
16 Imports System.IO
17 Imports System.Globalization
18 Imports System.Security.AccessControl
20 Namespace Microsoft.Samples.FileDemo
22 Friend Enum FileItemType
23 File
24 Directory
25 Other
26 End Enum
28 Friend Enum DefaultPropertiesView
29 General
30 Security
31 Other
32 End Enum
34 Friend Enum FileRightShortCuts
35 Read = FileSystemRights.ListDirectory Or FileSystemRights.ReadAttributes Or _
36 FileSystemRights.ReadExtendedAttributes Or FileSystemRights.ReadPermissions
37 ReadAndExecute = FileRightShortCuts.Read Or FileSystemRights.Traverse
38 Write = FileSystemRights.WriteData Or FileSystemRights.AppendData Or _
39 FileSystemRights.WriteExtendedAttributes Or _
40 FileSystemRights.WriteAttributes
41 Modify = FileRightShortCuts.ReadAndExecute Or FileRightShortCuts.Write Or _
42 FileSystemRights.Delete
43 FullControl = FileSystemRights.FullControl
44 End Enum
46 Module General
48 Public Enum DemoCategories
49 Created = 1
50 Moved = 2
51 Deleted = 3
52 End Enum
54 Public EnvironmentChanged As Boolean
55 Public curDir As String
56 Public NewName As String
57 Public NewValue As String
59 Public Function GetDriveType(ByVal d As DriveInfo, ByVal network As Boolean) As String
61 Dim typeName As String
63 Select Case d.DriveType
64 Case DriveType.Removable
65 typeName = "Floppy"
66 Case DriveType.CDRom
67 typeName = "CD Drive"
68 Case DriveType.Fixed
69 typeName = "Local Disk"
70 Case DriveType.Network
71 If Not network Then
72 typeName = "Network Drive"
73 Else
74 typeName = "Unknown"
75 End If
76 Case Else
77 typeName = "Unknown"
78 End Select
80 Return typeName
82 End Function
84 Public Function GetDriveIndex(ByVal d As DriveInfo) As Integer
86 Select Case d.DriveType
87 Case DriveType.Removable
88 Return 2
89 Case DriveType.CDRom
90 Return 0
91 Case DriveType.Fixed
92 Return 5
93 Case DriveType.Network
94 Return 7
95 End Select
97 Return 5
99 End Function
101 Public Function GetNameAndType(ByVal d As DriveInfo) As String
102 Return String.Format(CultureInfo.CurrentCulture, "{0} ({1})", GetDriveType(d, False), d.Name.Substring(0, 2))
103 End Function
104 End Module
105 End Namespace