Computer Name vs IP address

A forum devoted to the discussion of all topics having to do with scripting and other advanced programming using iX Developer.
Post Reply
s1fis
Posts: 3
Joined: Mon Oct 22, 2018 2:36 am
Location: Greece
Contact:

Computer Name vs IP address

Post 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
Attachments
ReadWriteNetworkLocation.zip
(29.21 KiB) Downloaded 474 times

User avatar
Russ C.
Posts: 213
Joined: Thu Nov 16, 2017 3:32 pm
Contact:

Re: Computer Name vs IP address

Post by Russ C. »

We see this most commonly when the HMI isn't connected to a DNS server
Best regards,

Russ
(801) 708-6690
Technical Support
Contact Us

Beijer Electronics AB
http://www.beijerelectronics.us

Post Reply