以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  当前块中已声明了局部变量  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=121714)

--  作者:ycwk
--  发布时间:2018/7/12 7:59:00
--  当前块中已声明了局部变量
   Dim ftp1 As New FtpClient
   ftp1.Host="172.16.1.1"
   ftp1.Account = "admin"
   ftp1.Password = "Admin"
   ftp1.UTF8=True



  If Tables("自助报障记录表").Current.IsNull("问题描述附件")=False Then    
     If ftp1.DeleteFile("\\各表附件\\自助报障记录表\\" & CurrentTable.Current("问题描述附件")) = True Then
        Messagebox.show("截图删除完成!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
        ftp1.Close
     Else
        Messagebox.show("截图删除失败!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
        ftp1.Close
     End If
  End If



Dim str_serialno As String =  e.Form.Controls("TB_日常问题ID").value & "_" & Format(Date.now, "yyMMddhhmmss") & ".jpg"

bit.save(ProjectPath & "RemoteFiles\\" & str_serialno)    \'保存图片到本地


运行下面代码报错,要怎么改?

\'上传到FTP服务器
Dim ftp1 As new ftpclient
ftp1.host="172.16.1.1" 
ftp1.Account = "admin"
ftp1.password = "Admin"
ftp1.UTF8=True


If ftp1.upload(ProjectPath & "RemoteFiles\\" & str_serialno,"\\各表附件\\自助报障记录表\\" & str_serialno)= True Then
    Messagebox.show("截图上传完成!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
    ftp1.Close
Else
    Messagebox.show("截图上传失败!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
    ftp1.Close
End If
[此贴子已经被作者于2018/7/12 7:59:55编辑过]

--  作者:有点甜
--  发布时间:2018/7/12 9:02:00
--  

Dim ftp1 As New FtpClient
ftp1.Host="172.16.1.1"
ftp1.Account = "admin"
ftp1.Password = "Admin"
ftp1.UTF8=True

If Tables("自助报障记录表").Current.IsNull("问题描述附件")=False Then
    If ftp1.DeleteFile("\\各表附件\\自助报障记录表\\" & CurrentTable.Current("问题描述附件")) = True Then
        Messagebox.show("截图删除完成!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
    Else
        Messagebox.show("截图删除失败!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
    End If
End If

 

 


Dim str_serialno As String =  e.Form.Controls("TB_日常问题ID").value & "_" & Format(Date.now, "yyMMddhhmmss") & ".jpg"


bit.save(ProjectPath & "RemoteFiles\\" & str_serialno)    \'保存图片到本地

If ftp1.upload(ProjectPath & "RemoteFiles\\" & str_serialno,"\\各表附件\\自助报障记录表\\" & str_serialno)= True Then
    Messagebox.show("截图上传完成!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
Else
    Messagebox.show("截图上传失败!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
End If
ftp1.Close

 


--  作者:ycwk
--  发布时间:2018/7/12 9:30:00
--  
运行到这里报截图上传失败


\'msgbox(0)
Dim myGraphics As Graphics = basemainform.CreateGraphics()
Dim s As new Size(2000, 1000) \'截取的大小
Dim bit As New Bitmap(s.Width, s.Height, myGraphics)
Dim memoryGraphics As Graphics = Graphics.FromImage(bit)
memoryGraphics.CopyFromScreen(0, 0, 0, 0, s) \'截取的开始位置,坐标(100, 200)


     Dim ftp1 As New FtpClient
     ftp1.Host="172.16.1.1"
     ftp1.Account = "admin"
     ftp1.Password = "Admin"
     ftp1.UTF8=True  


  If Tables("自助报障记录表").Current.IsNull("问题描述附件")=False Then  
     
     If ftp1.DeleteFile("\\各表附件\\自助报障记录表\\" & CurrentTable.Current("问题描述附件")) = True Then
        Messagebox.show("截图删除完成!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
     Else
        Messagebox.show("截图删除失败!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
     End If
  End If



Dim str_serialno As String =  e.Form.Controls("TB_日常问题ID").value & "_" & Format(Date.now, "yyMMddhhmmss") & ".jpg"


bit.save(ProjectPath & "RemoteFiles\\" & str_serialno)    \'保存图片到本地


\'上传到FTP服务器



If ftp1.upload(ProjectPath & "RemoteFiles\\" & str_serialno,"\\各表附件\\自助报障记录表\\" & str_serialno)= True Then
    Messagebox.show("截图上传完成!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
Else
    Messagebox.show("截图上传失败!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
End If
ftp1.close
[此贴子已经被作者于2018/7/12 9:31:43编辑过]

--  作者:ycwk
--  发布时间:2018/7/12 9:34:00
--  
下面这样的代码u pload函数是正常的,不知上面的代码为什么运行到u pload就报失败


Dim myGraphics As Graphics = basemainform.CreateGraphics()
Dim s As new Size(2000, 1000) \'截取的大小
Dim bit As New Bitmap(s.Width, s.Height, myGraphics)
Dim memoryGraphics As Graphics = Graphics.FromImage(bit)
memoryGraphics.CopyFromScreen(0, 0, 0, 0, s) \'截取的开始位置,坐标(100, 200)


     Dim ftp1 As New FtpClient
     ftp1.Host="172.16.1.1"
     ftp1.Account = "admin"
     ftp1.Password = "Admin"
     ftp1.UTF8=True  


  If Tables("自助报障记录表").Current.IsNull("问题描述附件")=False Then  
     
     If ftp1.D eleteFile("\\各表附件\\自助报障记录表\\" & CurrentTable.Current("问题描述附件")) = True Then
        Messagebox.show("截图删除完成!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
     Else
        Messagebox.show("截图删除失败!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
     End If
  End If



Dim str_serialno As String =  e.Form.Controls("TB_日常问题ID").value & "_" & Format(Date.now, "yyMMddhhmmss") & ".jpg"


bit.save(ProjectPath & "RemoteFiles\\" & str_serialno)    \'保存图片到本地


\'上传到FTP服务器



If ftp1.upload(ProjectPath & "RemoteFiles\\" & str_serialno,"\\各表附件\\自助报障记录表\\" & str_serialno)= True Then
    Messagebox.show("截图上传完成!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
Else
    Messagebox.show("截图上传失败!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
End If
ftp1.close


\'MessageBox.show(1)
Tables("自助报障记录表").Current("问题描述附件")= str_serialno     \'在"自助报障记录表"中保存上述图片路径
Tables("自助报障记录表").current.Save    



MessageBox.Show("截图成功!", "提示",MessageBoxButtons.Ok,MessageBoxIcon.Question, 0, Windows.forms.MessageBoxOptions.ServiceNotification)     \'模态窗口提示



Dim pbx As WinForm.PictureBox= Forms("软件自助报障系统窗口").Controls("PictureBox1")
pbx.SizeMode = ImageSizeMode.Zoom
pbx.Image = GetImage(ProjectPath & "RemoteFiles\\" & str_serialno)



--  作者:有点甜
--  发布时间:2018/7/12 9:37:00
--  

弹出这个路径

msgbox(ProjectPath & "RemoteFiles\\" & str_serialno)

看弹出的路径,对应的文件是否存在。

 

如果文件存在,就是你ftp的信息输入不正确。执行下面代码,看能否连上ftp

 

Dim ftp1 As New FtpClient
ftp1.Host="172.16.5.89"
ftp1.Account = "administrator"
ftp1.Password = "Admin1234"
ftp1.UTF8=True
ftp1.OpenManager


--  作者:ycwk
--  发布时间:2018/7/12 10:06:00
--  
把 ftp1.UTF8=true  屏蔽掉就好了,可能是中文文件夹显示为乱码的原因