Page 1 of 1

Computer Name vs IP address

Posted: Tue Jul 16, 2019 5:18 am
by s1fis
Hello to everybody,

Firstly, FYI I'm new in scripting.
My project is to copy my csv files to a network path.
Based on the attached sample "ReadWriteNetworkLocation"- BTW thank you very much - I concluded to the following:

public partial class Tags
{
string networkPath = @"\\<ComputerName>\My documents\NewFolder"; //*********EDIT THIS TO BE YOUR NETWORK FILE PATH**********// //Please note: If writing to Windows 10, the windows Feature SMB 1.0 Server must be enabled
string sourcePath = @"\FlashDrive\Project\Project Files\DatabaseExport\Data Loggers";
string fileName, fullFilePath;

void Save_Log_to_USB1_ValueOn(System.Object sender, System.EventArgs e)
{
try
{
foreach (string f in Directory.GetDirectories(sourcePath))
{
string dPath = f;
foreach(string d in Directory.GetFiles(dPath, "*.csv"))
{
string dName = d.Substring(dPath.Length +1);
string extension = Path.GetExtension(d);

if(extension != null && (extension.Equals(".csv")))
{
File.Copy(Path.Combine(dPath, dName), Path.Combine(networkPath, dName), true);
File.Delete(Path.Combine(dPath, dName)); // Delete the file after copying & Ovewrite - working - 18/6/2019 tested
}
}
}
Globals.Tags.Write_Success.Value = "Success writing to file: " +fullFilePath+Environment.NewLine+Environment.NewLine;
// Globals.Tags.Write_Success.Value += "Wrote line: "+s;
}
catch(Exception ex)
{
Globals.Tags.Write_Success.Value = ex.ToString();
}
}

The result is good. It works.
My questions are
1. If I replace the <ComputerName> with the IP address, it doesn't work.
2. It never worked in Win10 even if enabled the SMB 1.0. All the trials are in Win7.

But my biggest worry is why it doesn't work by using the IP address instead of the ComputerName.

Any suggestions? :)

Thanks in advance.

Iosif

Re: Computer Name vs IP address

Posted: Tue Oct 22, 2019 2:52 pm
by Russ C.
We see this most commonly when the HMI isn't connected to a DNS server