CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
山寨机中的战斗机! 程序优化工程师到底对IT界有没有贡献
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  VB >  基础类

急:通过局域网向服务器不定时传送文件

楼主ddall(小路)2002-04-17 14:08:20 在 VB / 基础类 提问

各位大侠:  
  我想通过局域网向服务器不定时传送文件,但不能用写库的形式,最好是直接将文件传到服务器的某个文件加下,请问该怎样实现?如果用winsock的话,在服务器段还得加一个程序,有没有简单的方法?谢谢。 问题点数:100、回复次数:7Top

1 楼_1_(该用户已封杀)回复于 2002-04-17 14:11:39 得分 0

ftp        
  或者用filecopyTop

2 楼SnHnBn(大可达)回复于 2002-04-17 14:13:16 得分 0

服务器共享文件夹(开放写权限),然后CopyFile不就得了。服务器路径写法:"\\ServerName\PathName\FileName.ext"Top

3 楼gump2000(阿甘)回复于 2002-04-17 14:17:24 得分 0

http://www.21code.com/codebase/?pos=down&id=704  
  http://www.21code.com/codebase/?pos=down&id=698  
  您可以看看以上两个例子代码来MAP一个网络驱动器  
  然后用FileCopy来完成您想要的工作  
   
  BTW:以上两个代码支持带密码的网络驱动器MAPTop

4 楼sundy_RAO(sundy_RAO)回复于 2002-04-17 15:18:22 得分 0

请问,   如果要备份ACCESS数据库该怎么办呢?且要备份的数据库当前正在使用中。Top

5 楼gump2000(阿甘)回复于 2002-04-17 15:22:01 得分 0

使用filesystemobject的copy或者用API--CopyFile  
  Top

6 楼gump2000(阿甘)回复于 2002-04-17 15:22:51 得分 100

'in   a   form   (Form1)  
  Private   Sub   Form_Load()  
          'KPD-Team   2001  
          'URL:   http://www.allapi.net/  
          'E-Mail:   KPDTeam@Allapi.net  
          Dim   Ret   As   Long  
          'set   the   graphics   mode   to   persistent  
          Me.AutoRedraw   =   True  
          'print   some   text  
          Me.Print   "Click   the   form   to   abort   the   filecopy"  
          'show   the   form  
          Me.Show  
          'start   copying  
          Ret   =   CopyFileEx("c:\verybigfile.ext",   "c:\copy.ext",   AddressOf   CopyProgressRoutine,   ByVal   0&,   bCancel,   COPY_FILE_RESTARTABLE)  
          'show   some   text  
          Me.Print   "Filecopy   completed   "   +   IIf(Ret   =   0,   "(ERROR/ABORTED)",   "successfully")  
  End   Sub  
  Private   Sub   Form_Click()  
          'cancel   filecopy  
          bCancel   =   1  
  End   Sub  
  'in   a   module  
  Public   Const   PROGRESS_CANCEL   =   1  
  Public   Const   PROGRESS_CONTINUE   =   0  
  Public   Const   PROGRESS_QUIET   =   3  
  Public   Const   PROGRESS_STOP   =   2  
  Public   Const   COPY_FILE_FAIL_IF_EXISTS   =   &H1  
  Public   Const   COPY_FILE_RESTARTABLE   =   &H2  
  Public   Declare   Function   CopyFileEx   Lib   "kernel32.dll"   Alias   "CopyFileExA"   (ByVal   lpExistingFileName   As   String,   ByVal   lpNewFileName   As   String,   ByVal   lpProgressRoutine   As   Long,   lpData   As   Any,   ByRef   pbCancel   As   Long,   ByVal   dwCopyFlags   As   Long)   As   Long  
  Public   bCancel   As   Long  
  Public   Function   CopyProgressRoutine(ByVal   TotalFileSize   As   Currency,   ByVal   TotalBytesTransferred   As   Currency,   ByVal   StreamSize   As   Currency,   ByVal   StreamBytesTransferred   As   Currency,   ByVal   dwStreamNumber   As   Long,   ByVal   dwCallbackReason   As   Long,   ByVal   hSourceFile   As   Long,   ByVal   hDestinationFile   As   Long,   ByVal   lpData   As   Long)   As   Long  
          'adjust   the   caption  
          Form1.Caption   =   CStr(Int((TotalBytesTransferred   *   10000)   /   (TotalFileSize   *   10000)   *   100))   +   "%   complete..."  
          'allow   user   input  
          DoEvents  
          'continue   filecopy  
          CopyProgressRoutine   =   PROGRESS_CONTINUE  
  End   Function  
  Top

7 楼gump2000(阿甘)回复于 2002-04-17 15:22:58 得分 0

'This   program   needs   a   Dialog   box,   named   CDBox1  
  '     (To   add   the   Common   Dialog   Box   to   your   tools   menu,   go   to   Project->Components   (or   press   CTRL-T)  
  '       and   select   Microsoft   Common   Dialog   control)  
  Private   Type   FILETIME  
          dwLowDateTime   As   Long  
          dwHighDateTime   As   Long  
  End   Type  
  Private   Type   SHFILEOPSTRUCT  
          hWnd   As   Long  
          wFunc   As   Long  
          pFrom   As   String  
          pTo   As   String  
          fFlags   As   Integer  
          fAborted   As   Boolean  
          hNameMaps   As   Long  
          sProgress   As   String  
  End   Type  
  Private   Type   SYSTEMTIME  
          wYear   As   Integer  
          wMonth   As   Integer  
          wDayOfWeek   As   Integer  
          wDay   As   Integer  
          wHour   As   Integer  
          wMinute   As   Integer  
          wSecond   As   Integer  
          wMilliseconds   As   Integer  
  End   Type  
  Private   Const   GENERIC_WRITE   =   &H40000000  
  Private   Const   OPEN_EXISTING   =   3  
  Private   Const   FILE_SHARE_READ   =   &H1  
  Private   Const   FILE_SHARE_WRITE   =   &H2  
  Private   Const   FO_DELETE   =   &H3  
  Private   Declare   Function   CopyFile   Lib   "kernel32"   Alias   "CopyFileA"   (ByVal   lpExistingFileName   As   String,   ByVal   lpNewFileName   As   String,   ByVal   bFailIfExists   As   Long)   As   Long  
  Private   Declare   Function   CreateDirectory   Lib   "kernel32"   Alias   "CreateDirectoryA"   (ByVal   lpPathName   As   String,   lpSecurityAttributes   As   Long)   As   Long  
  Private   Declare   Function   DeleteFile   Lib   "kernel32"   Alias   "DeleteFileA"   (ByVal   lpFileName   As   String)   As   Long  
  Private   Declare   Function   GetFileSize   Lib   "kernel32"   (ByVal   hFile   As   Long,   lpFileSizeHigh   As   Long)   As   Long  
  Private   Declare   Function   GetFileTime   Lib   "kernel32"   (ByVal   hFile   As   Long,   lpCreationTime   As   FILETIME,   lpLastAccessTime   As   FILETIME,   lpLastWriteTime   As   FILETIME)   As   Long  
  Private   Declare   Function   MoveFile   Lib   "kernel32"   Alias   "MoveFileA"   (ByVal   lpExistingFileName   As   String,   ByVal   lpNewFileName   As   String)   As   Long  
  Private   Declare   Function   CreateFile   Lib   "kernel32"   Alias   "CreateFileA"   (ByVal   lpFileName   As   String,   ByVal   dwDesiredAccess   As   Long,   ByVal   dwShareMode   As   Long,   lpSecurityAttributes   As   Long,   ByVal   dwCreationDisposition   As   Long,   ByVal   dwFlagsAndAttributes   As   Long,   ByVal   hTemplateFile   As   Long)   As   Long  
  Private   Declare   Function   CloseHandle   Lib   "kernel32"   (ByVal   hObject   As   Long)   As   Long  
  Private   Declare   Function   SHFileOperation   Lib   "shell32.dll"   Alias   "SHFileOperationA"   (lpFileOp   As   SHFILEOPSTRUCT)   As   Long  
  Private   Declare   Function   FileTimeToSystemTime   Lib   "kernel32"   (lpFileTime   As   FILETIME,   lpSystemTime   As   SYSTEMTIME)   As   Long  
  Private   Declare   Function   FileTimeToLocalFileTime   Lib   "kernel32"   (lpFileTime   As   FILETIME,   lpLocalFileTime   As   FILETIME)   As   Long  
  Private   Sub   Form_Load()  
          'KPD-Team   1998  
          'URL:   http://www.allapi.net/  
          'E-Mail:   KPDTeam@Allapi.net  
          Dim   lngHandle   As   Long,   SHDirOp   As   SHFILEOPSTRUCT,   lngLong   As   Long  
          Dim   Ft1   As   FILETIME,   Ft2   As   FILETIME,   SysTime   As   SYSTEMTIME  
          'Set   the   dialog's   title  
          CDBox.DialogTitle   =   "Choose   a   file   ..."  
          'Raise   an   error   when   the   user   pressed   cancel  
          CDBox.CancelError   =   True  
          'Show   the   'Open   File'-dialog  
          CDBox.ShowOpen  
          'Create   a   new   directory  
          CreateDirectory   "C:\KPD-Team",   ByVal   &H0  
          'Copy   the   selected   file   to   our   new   directory  
          CopyFile   CDBox.filename,   "C:\KPD-Team\"   +   CDBox.FileTitle,   0  
          'Rename   the   file  
          MoveFile   "C:\KPD-Team\"   +   CDBox.FileTitle,   "C:\KPD-Team\test.kpd"  
          'Open   the   file  
          lngHandle   =   CreateFile("C:\KPD-Team\test.kpd",   GENERIC_WRITE,   FILE_SHARE_READ   Or   FILE_SHARE_WRITE,   ByVal   0&,   OPEN_EXISTING,   0,   0)  
          'Get   the   file's   size  
          MsgBox   "The   size   of   the   selected   file   is"   +   Str$(GetFileSize(lngHandle,   lngLong))   +   "   bytes."  
          'Get   the   fil's   time  
          GetFileTime   lngHandle,   Ft1,   Ft1,   Ft2  
          'Convert   the   file   time   to   the   local   file   time  
          FileTimeToLocalFileTime   Ft2,   Ft1  
          'Convert   the   file   time   to   system   file   time  
          FileTimeToSystemTime   Ft1,   SysTime  
          MsgBox   "The   selected   file   was   created   on"   +   Str$(SysTime.wMonth)   +   "/"   +   LTrim(Str$(SysTime.wDay))   +   "/"   +   LTrim(Str$(SysTime.wYear))  
          'Close   the   file  
          CloseHandle   lngHandle  
          'Delete   the   file  
          DeleteFile   "C:\KPD-Team\test.kpd"  
          With   SHDirOp  
                  .wFunc   =   FO_DELETE  
                  .pFrom   =   "C:\KPD-Team"  
          End   With  
          'Delete   the   directory  
          SHFileOperation   SHDirOp  
          End  
  End   Sub  
  Top

相关问题

  • 局域网文件传送
  • 在局域网中Win98机器怎样查看Novell服务器上的文件?
  • 如何读取局域网内服务器的某个文件的信息?
  • 在局域网里不能访问我的win2000服务器的文件
  • 局域网内将客户端的文件拷贝到服务器端
  • 在VB中怎么实现局域网里的文件传送?
  • 我想访问局域网中服务器中的一个文件,但告诉我连接被拒绝!
  • 在带有域的局域网内如何安装samba服务器实现文件共享。
  • 在局域网中怎样建立两个不同域的机器都可以下载文件的服务器?
  • 【新年好!!!局域网内的服务器上下载(拷贝)一个文件到本地,请教!!!】

关键词

  • .net
  • 服务器
  • 文件
  • me
  • filecopy
  • progress
  • copy
  • ext
  • ret
  • show

得分解答快速导航

  • 帖主:ddall
  • gump2000

相关链接

  • Visual Basic类图书
  • Visual Basic类源码下载

广告也精彩

反馈

请通过下述方式给我们反馈
反馈
提问
网站简介|广告服务|VIP资费标准|银行汇款帐号|网站地图|帮助|联系方式|诚聘英才|English|问题报告
北京创新乐知广告有限公司 版权所有, 京 ICP 证 070598 号
世纪乐知(北京)网络技术有限公司 提供技术支持
Copyright © 2000-2008, CSDN.NET, All Rights Reserved
GongshangLogo