473,378 Members | 1,413 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Filecopy With Ip Address

1
Hi all, I´m not speak english so well, but i'll try to do it better. I have a problem with the filecopy function when i use the IP instead of a computer name. For example

This sentence works ok
FileCopy "\\gdl1mfg994\qualcomm\k2.pdf", "\\gdl1me090\dibujos\bety.pdf"

But this doesn't work
FileCopy "\\168.192.1.16\qualcomm\k2.pdf", "\\168.190.4.14\dibujos\bety.pdf"

It display this error: "path not found"

Can anybody help me???
Feb 1 '08 #1
3 2427
Hi all, I´m not speak english so well, but i'll try to do it better. I have a problem with the filecopy function when i use the IP instead of a computer name. For example

This sentence works ok
FileCopy "\\gdl1mfg994\qualcomm\k2.pdf", "\\gdl1me090\dibujos\bety.pdf"

But this doesn't work
FileCopy "\\168.192.1.16\qualcomm\k2.pdf", "\\168.190.4.14\dibujos\bety.pdf"

It display this error: "path not found"

Can anybody help me???
Hi,
Do u try by the Internet Transfer Control?
Feb 2 '08 #2
kZero
23
Hello,
you have first to convert the ip to hostname to copy
you can use this code

Expand|Select|Wrap|Line Numbers
  1. '**************************************
  2. 'Windows API/Global Declarations for :IP
  3. '     Resolver - IP Address Convert to Hostnam
  4. '     e
  5. '**************************************
  6. 'PUT THIS IS A MODULE
  7. Option Explicit
  8. '||================================||
  9. '|| Remember to use:||
  10. '|| WSACleanup in Form_Unload()||
  11. '|| IP_Initialize in Form_Load() ||
  12. '||================================||
  13. Const WSADescription_Len = 256
  14. Const WSASYS_Status_Len = 128
  15.  
  16.  
  17. Private Type HOSTENT
  18.     hName As Long
  19.     hAliases As Long
  20.     hAddrType As Integer
  21.     hLength As Integer
  22.     hAddrList As Long
  23.     End Type
  24.  
  25.  
  26. Private Type WSADATA
  27.     wversion As Integer
  28.     wHighVersion As Integer
  29.     szDescription(0 To WSADescription_Len) As Byte
  30.     szSystemStatus(0 To WSASYS_Status_Len) As Byte
  31.     iMaxSockets As Integer
  32.     iMaxUdpDg As Integer
  33.     lpszVendorInfo As Long
  34.     End Type
  35.  
  36.  
  37. Declare Function WSACleanup Lib "wsock32" () As Long
  38.  
  39.  
  40. Private Declare Function WSAStartup Lib "wsock32" _
  41.     (ByVal VersionReq As Long, WSADataReturn As WSADATA) As Long
  42.  
  43.  
  44. Private Declare Function WSAGetLastError Lib "wsock32" () As Long
  45.  
  46.  
  47. Private Declare Function gethostbyaddr Lib "wsock32" (addr As Long, addrLen As Long, _
  48.     addrType As Long) As Long
  49.  
  50.  
  51. Private Declare Function gethostbyname Lib "wsock32" (ByVal hostname As String) As Long
  52.  
  53.  
  54. Private Declare Sub RtlMoveMemory Lib "kernel32" (hpvDest As Any, ByVal hpvSource As Long, _
  55.     ByVal cbCopy As Long)
  56.     'checks if string is valid IP address
  57.  
  58.  
  59. Private Function IsIP(ByVal strIP As String) As Boolean
  60.     On Error Resume Next
  61.     Dim t As String: Dim s As String: Dim i As Integer
  62.     s = strIP
  63.  
  64.  
  65.     While InStr(s, ".") <> 0
  66.         t = Left(s, InStr(s, ".") - 1)
  67.         If IsNumeric(t) And Val(t) >= 0 And Val(t) <= 255 Then s = Mid(s, InStr(s, ".") + 1) _
  68.     Else Exit Function
  69.         i = i + 1
  70.     Wend
  71.     t = s
  72.     If IsNumeric(t) And InStr(t, ".") = 0 And Len(t) = Len(Trim(Str(Val(t)))) And _
  73.     Val(t) >= 0 And Val(t) <= 255 And strIP <> "255.255.255.255" And i = 3 Then IsIP = True
  74.  
  75.  
  76.     If Err.Number > 0 Then
  77.         MsgBox Err.Description, , Err.Number
  78.         Err.Clear
  79.     End If
  80. End Function
  81. 'converts IP address from string to sin_
  82. '     addr
  83.  
  84.  
  85. Private Function MakeIP(strIP As String) As Long
  86.     On Error Resume Next
  87.     Dim lIP As Long
  88.     lIP = Left(strIP, InStr(strIP, ".") - 1)
  89.     strIP = Mid(strIP, InStr(strIP, ".") + 1)
  90.     lIP = lIP + Left(strIP, InStr(strIP, ".") - 1) * 256
  91.     strIP = Mid(strIP, InStr(strIP, ".") + 1)
  92.     lIP = lIP + Left(strIP, InStr(strIP, ".") - 1) * 256 * 256
  93.     strIP = Mid(strIP, InStr(strIP, ".") + 1)
  94.  
  95.  
  96.     If strIP < 128 Then
  97.         lIP = lIP + strIP * 256 * 256 * 256
  98.     Else
  99.         lIP = lIP + (strIP - 256) * 256 * 256 * 256
  100.     End If
  101.     MakeIP = lIP
  102.  
  103.  
  104.     If Err.Number > 0 Then
  105.         MsgBox Err.Description, , Err.Number
  106.         Err.Clear
  107.     End If
  108. End Function
  109. 'resolves IP address to host name
  110.  
  111.  
  112. Function NameByAddr(strAddr As String) As String
  113.     On Error Resume Next
  114.     Dim nRet As Long
  115.     Dim lIP As Long
  116.     Dim strHost As String * 255: Dim strTemp As String
  117.     Dim hst As HOSTENT
  118.  
  119.  
  120.  
  121.     If IsIP(strAddr) Then
  122.         lIP = MakeIP(strAddr)
  123.         nRet = gethostbyaddr(lIP, 4, 2)
  124.  
  125.  
  126.         If nRet <> 0 Then
  127.             RtlMoveMemory hst, nRet, Len(hst)
  128.             RtlMoveMemory ByVal strHost, hst.hName, 255
  129.             strTemp = strHost
  130.             If InStr(strTemp, Chr(10)) <> 0 Then strTemp = Left(strTemp, InStr(strTemp, Chr(0)) - 1)
  131.             strTemp = Trim(strTemp)
  132.             NameByAddr = strTemp
  133.         Else
  134.             MsgBox "Host name Not found", , "9003"
  135.             Exit Function
  136.         End If
  137.     Else
  138.         MsgBox "Invalid IP address", , "9002"
  139.         Exit Function
  140.     End If
  141.  
  142.  
  143.     If Err.Number > 0 Then
  144.         MsgBox Err.Description, , Err.Number
  145.         Err.Clear
  146.     End If
  147. End Function
  148. 'resolves host name to IP address
  149.  
  150.  
  151. Function AddrByName(ByVal strHost As String)
  152.     On Error Resume Next
  153.     Dim hostent_addr As Long
  154.     Dim hst As HOSTENT
  155.     Dim hostip_addr As Long
  156.     Dim temp_ip_address() As Byte
  157.     Dim i As Integer
  158.     Dim ip_address As String
  159.  
  160.  
  161.     If IsIP(strHost) Then
  162.         AddrByName = strHost
  163.         Exit Function
  164.     End If
  165.     hostent_addr = gethostbyname(strHost)
  166.  
  167.  
  168.     If hostent_addr = 0 Then
  169.         MsgBox "Can't resolve hst", , "9001"
  170.         Exit Function
  171.     End If
  172.     RtlMoveMemory hst, hostent_addr, LenB(hst)
  173.     RtlMoveMemory hostip_addr, hst.hAddrList, 4
  174.     ReDim temp_ip_address(1 To hst.hLength)
  175.     RtlMoveMemory temp_ip_address(1), hostip_addr, hst.hLength
  176.  
  177.  
  178.     For i = 1 To hst.hLength
  179.         ip_address = ip_address & temp_ip_address(i) & "."
  180.     Next
  181.     ip_address = Mid(ip_address, 1, Len(ip_address) - 1)
  182.     AddrByName = ip_address
  183.  
  184.  
  185.     If Err.Number > 0 Then
  186.         MsgBox Err.Description, , Err.Number
  187.         Err.Clear
  188.     End If
  189. End Function
  190.  
  191.  
  192. Sub IP_Initialize()
  193.     Dim udtWSAData As WSADATA
  194.  
  195.  
  196.     If WSAStartup(257, udtWSAData) Then
  197.         MsgBox Err.Description, , Err.LastDllError
  198.     End If
  199. End Sub
  200. '||================================||
  201. '|| Remember to use:||
  202. '|| WSACleanup in Form_Unload()||
  203. '|| IP_Initialize in Form_Load() ||
  204. '||================================||
  205.  
  206.  
Expand|Select|Wrap|Line Numbers
  1. 'How do you call these Functions?
  2. Option Explicit
  3.  
  4.  
  5. Private Sub Command1_Click()
  6.     Text1.Text = NameByAddr(Text2)
  7. End Sub
  8.  
  9.  
  10. Private Sub Command2_Click()
  11.     Text2.Text = AddrByName("www.yahoo.com")
  12. End Sub
  13.  
  14.  
  15. Private Sub Form_Load()
  16.     IP_Initialize
  17. End Sub
  18.  
  19.  
  20. Private Sub Form_Unload(Cancel As Integer)
  21.     WSACleanup
  22. End Sub
  23.  
Feb 2 '08 #3
Hello,
you have first to convert the ip to hostname to copy
you can use this code

Expand|Select|Wrap|Line Numbers
  1. '**************************************
  2. 'Windows API/Global Declarations for :IP
  3. '     Resolver - IP Address Convert to Hostnam
  4. '     e
  5. '**************************************
  6. 'PUT THIS IS A MODULE
  7. Option Explicit
  8. '||================================||
  9. '|| Remember to use:||
  10. '|| WSACleanup in Form_Unload()||
  11. '|| IP_Initialize in Form_Load() ||
  12. '||================================||
  13. Const WSADescription_Len = 256
  14. Const WSASYS_Status_Len = 128
  15.  
  16.  
  17. Private Type HOSTENT
  18.     hName As Long
  19.     hAliases As Long
  20.     hAddrType As Integer
  21.     hLength As Integer
  22.     hAddrList As Long
  23.     End Type
  24.  
  25.  
  26. Private Type WSADATA
  27.     wversion As Integer
  28.     wHighVersion As Integer
  29.     szDescription(0 To WSADescription_Len) As Byte
  30.     szSystemStatus(0 To WSASYS_Status_Len) As Byte
  31.     iMaxSockets As Integer
  32.     iMaxUdpDg As Integer
  33.     lpszVendorInfo As Long
  34.     End Type
  35.  
  36.  
  37. Declare Function WSACleanup Lib "wsock32" () As Long
  38.  
  39.  
  40. Private Declare Function WSAStartup Lib "wsock32" _
  41.     (ByVal VersionReq As Long, WSADataReturn As WSADATA) As Long
  42.  
  43.  
  44. Private Declare Function WSAGetLastError Lib "wsock32" () As Long
  45.  
  46.  
  47. Private Declare Function gethostbyaddr Lib "wsock32" (addr As Long, addrLen As Long, _
  48.     addrType As Long) As Long
  49.  
  50.  
  51. Private Declare Function gethostbyname Lib "wsock32" (ByVal hostname As String) As Long
  52.  
  53.  
  54. Private Declare Sub RtlMoveMemory Lib "kernel32" (hpvDest As Any, ByVal hpvSource As Long, _
  55.     ByVal cbCopy As Long)
  56.     'checks if string is valid IP address
  57.  
  58.  
  59. Private Function IsIP(ByVal strIP As String) As Boolean
  60.     On Error Resume Next
  61.     Dim t As String: Dim s As String: Dim i As Integer
  62.     s = strIP
  63.  
  64.  
  65.     While InStr(s, ".") <> 0
  66.         t = Left(s, InStr(s, ".") - 1)
  67.         If IsNumeric(t) And Val(t) >= 0 And Val(t) <= 255 Then s = Mid(s, InStr(s, ".") + 1) _
  68.     Else Exit Function
  69.         i = i + 1
  70.     Wend
  71.     t = s
  72.     If IsNumeric(t) And InStr(t, ".") = 0 And Len(t) = Len(Trim(Str(Val(t)))) And _
  73.     Val(t) >= 0 And Val(t) <= 255 And strIP <> "255.255.255.255" And i = 3 Then IsIP = True
  74.  
  75.  
  76.     If Err.Number > 0 Then
  77.         MsgBox Err.Description, , Err.Number
  78.         Err.Clear
  79.     End If
  80. End Function
  81. 'converts IP address from string to sin_
  82. '     addr
  83.  
  84.  
  85. Private Function MakeIP(strIP As String) As Long
  86.     On Error Resume Next
  87.     Dim lIP As Long
  88.     lIP = Left(strIP, InStr(strIP, ".") - 1)
  89.     strIP = Mid(strIP, InStr(strIP, ".") + 1)
  90.     lIP = lIP + Left(strIP, InStr(strIP, ".") - 1) * 256
  91.     strIP = Mid(strIP, InStr(strIP, ".") + 1)
  92.     lIP = lIP + Left(strIP, InStr(strIP, ".") - 1) * 256 * 256
  93.     strIP = Mid(strIP, InStr(strIP, ".") + 1)
  94.  
  95.  
  96.     If strIP < 128 Then
  97.         lIP = lIP + strIP * 256 * 256 * 256
  98.     Else
  99.         lIP = lIP + (strIP - 256) * 256 * 256 * 256
  100.     End If
  101.     MakeIP = lIP
  102.  
  103.  
  104.     If Err.Number > 0 Then
  105.         MsgBox Err.Description, , Err.Number
  106.         Err.Clear
  107.     End If
  108. End Function
  109. 'resolves IP address to host name
  110.  
  111.  
  112. Function NameByAddr(strAddr As String) As String
  113.     On Error Resume Next
  114.     Dim nRet As Long
  115.     Dim lIP As Long
  116.     Dim strHost As String * 255: Dim strTemp As String
  117.     Dim hst As HOSTENT
  118.  
  119.  
  120.  
  121.     If IsIP(strAddr) Then
  122.         lIP = MakeIP(strAddr)
  123.         nRet = gethostbyaddr(lIP, 4, 2)
  124.  
  125.  
  126.         If nRet <> 0 Then
  127.             RtlMoveMemory hst, nRet, Len(hst)
  128.             RtlMoveMemory ByVal strHost, hst.hName, 255
  129.             strTemp = strHost
  130.             If InStr(strTemp, Chr(10)) <> 0 Then strTemp = Left(strTemp, InStr(strTemp, Chr(0)) - 1)
  131.             strTemp = Trim(strTemp)
  132.             NameByAddr = strTemp
  133.         Else
  134.             MsgBox "Host name Not found", , "9003"
  135.             Exit Function
  136.         End If
  137.     Else
  138.         MsgBox "Invalid IP address", , "9002"
  139.         Exit Function
  140.     End If
  141.  
  142.  
  143.     If Err.Number > 0 Then
  144.         MsgBox Err.Description, , Err.Number
  145.         Err.Clear
  146.     End If
  147. End Function
  148. 'resolves host name to IP address
  149.  
  150.  
  151. Function AddrByName(ByVal strHost As String)
  152.     On Error Resume Next
  153.     Dim hostent_addr As Long
  154.     Dim hst As HOSTENT
  155.     Dim hostip_addr As Long
  156.     Dim temp_ip_address() As Byte
  157.     Dim i As Integer
  158.     Dim ip_address As String
  159.  
  160.  
  161.     If IsIP(strHost) Then
  162.         AddrByName = strHost
  163.         Exit Function
  164.     End If
  165.     hostent_addr = gethostbyname(strHost)
  166.  
  167.  
  168.     If hostent_addr = 0 Then
  169.         MsgBox "Can't resolve hst", , "9001"
  170.         Exit Function
  171.     End If
  172.     RtlMoveMemory hst, hostent_addr, LenB(hst)
  173.     RtlMoveMemory hostip_addr, hst.hAddrList, 4
  174.     ReDim temp_ip_address(1 To hst.hLength)
  175.     RtlMoveMemory temp_ip_address(1), hostip_addr, hst.hLength
  176.  
  177.  
  178.     For i = 1 To hst.hLength
  179.         ip_address = ip_address & temp_ip_address(i) & "."
  180.     Next
  181.     ip_address = Mid(ip_address, 1, Len(ip_address) - 1)
  182.     AddrByName = ip_address
  183.  
  184.  
  185.     If Err.Number > 0 Then
  186.         MsgBox Err.Description, , Err.Number
  187.         Err.Clear
  188.     End If
  189. End Function
  190.  
  191.  
  192. Sub IP_Initialize()
  193.     Dim udtWSAData As WSADATA
  194.  
  195.  
  196.     If WSAStartup(257, udtWSAData) Then
  197.         MsgBox Err.Description, , Err.LastDllError
  198.     End If
  199. End Sub
  200. '||================================||
  201. '|| Remember to use:||
  202. '|| WSACleanup in Form_Unload()||
  203. '|| IP_Initialize in Form_Load() ||
  204. '||================================||
  205.  
  206.  
Expand|Select|Wrap|Line Numbers
  1. 'How do you call these Functions?
  2. Option Explicit
  3.  
  4.  
  5. Private Sub Command1_Click()
  6.     Text1.Text = NameByAddr(Text2)
  7. End Sub
  8.  
  9.  
  10. Private Sub Command2_Click()
  11.     Text2.Text = AddrByName("www.yahoo.com")
  12. End Sub
  13.  
  14.  
  15. Private Sub Form_Load()
  16.     IP_Initialize
  17. End Sub
  18.  
  19.  
  20. Private Sub Form_Unload(Cancel As Integer)
  21.     WSACleanup
  22. End Sub
  23.  
If it works, its a great archive for all of us. Thanks.
Feb 2 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: Thomas J. Clancy | last post by:
I was wondering if anyone knew of a way to use std::copy() and istream_iterator<>/ostream_iterator<> write a file copy function that is quick and efficient. Doing this messes up the file because...
1
by: Beryl Small | last post by:
I have a web application in Visual Studio.Net 2003. On the click event of a button on my .aspx page, I use the following FileCopy SourceFile, DestinationFil the Sourcefile is on a mapped drive...
6
by: deko | last post by:
In a multi-user environment, I have a table that stores hyperlinks to documents that are stored on the machine that hosts the mdb database. The table entry looks like this: ...
9
by: cantelow | last post by:
Hi. I've got a program printing multiple pdf reports, and I need to wait for completion of various associated operations- The pdf printer prints to one file, then I need to copy that where I need...
3
by: Lou | last post by:
I have a file name witha wildcard: "D:\myFolder\Logo1.*tga" There are 50 files that match this wilcard. I want to copy these 50 files to another directory I Tried...
0
by: daniele.balducci | last post by:
Hi All, I'm experiencing troubles in a simple .net web application. The applicatione is made up by a single form looping to move some files to a different folder . the main loop is as follows...
4
by: =?Utf-8?B?UnVpIE9saXZlaXJh?= | last post by:
Where can I find XP version of FILECOPY.AVI, to use in a dialog? There is a movie called FILECOPY.AVI which is included with Visual Studio 2005, but it is the 16 bit (Windows 95) version. There...
7
by: bhughes2187 | last post by:
In my app I am creating, there is a procedure that does a file copy from the local drive to a network share. The issue I am having, is even though I have the share mapped, and I can browse to the...
7
by: TracyWants2Know | last post by:
Access Version: 2002 SP3 OS: MS Windows XP Professional Code from Module: Dim txtFileNameBuES As String Dim txtFileNameBuESXP As String Dim txtPathNameBuTo As String ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.