- 作者:zhaozj
- 发表时间:2020-12-23 10:52
- 来源:未知
Imports System.Web.ServicesImports System.ConfigurationImports System.IO
<WebService(Namespace:="http://www.dynamics-apps.com")> _Public Class FileServer Inherits System.Web.Services.WebService
#Region " Web Services Designer Generated Code "
Public Sub New() MyBase.New()
'This call is required by the Web Services Designer. InitializeComponent()
'Add your own initialization code after the InitializeComponent() call End Sub
'Required by the Web Services Designer Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Web Services Designer 'It can be modified using the Web Services Designer. 'Do not modify it using the code editor. <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() components = New System.ComponentModel.Container() End Sub
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) 'CODEGEN: This procedure is required by the Web Services Designer 'Do not modify it using the code editor. If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub
#End Region
Private Shared WebServerPath As String = ConfigurationSettings.AppSettings("WebServerRootPath")
Public Enum FileExtensions htm html asp aspx jpg gif dll exe all End Enum
Public Class FileInformation Public Name As String Public Size As Long Public CreadedDate As DateTime Public LastModified As DateTime Public LastAccess As DateTime Public FileType As String Public FileLocation As String Public FileContent As Byte() End Class
<WebMethod(Description:="Retrieve a boolean indicating if Path exists or not in WebServer")> _ Public Function DirectoryExists(ByVal Path As String) As Boolean Dim di As New DirectoryInfo(WebServerPath & Path) Return di.Exists End Function
<WebMethod(Description:="Retrieve a boolean indicating if File exists or not in WebServer")> _ Public Function FileExists(ByVal Path As String, ByVal FileName As String) As Boolean Dim di As DirectoryInfo Dim fi As FileInfo Try di = New DirectoryInfo(WebServerPath & Path) If Not di.Exists Then Return False Exit Function End If Dim afi As FileInfo() = di.GetFiles() For Each fi In afi If fi.Name = FileName Then Return True Exit For End If Next Catch Return False End Try