Rename Name of Exported Dataloger throught textbox

A forum devoted to the discussion of all topics having to do with scripting and other advanced programming using iX Developer.
Post Reply
JohnCZ
Posts: 73
Joined: Wed Jun 27, 2012 1:17 am
Location: CZ
Contact:

Rename Name of Exported Dataloger throught textbox

Post by JohnCZ »

Hello,

My question is simple. I have a project (T7A) where the operator enters into the textbox name of the exported datalogger1 and when he clicks on the button, Datalogger1 will save CSV file to USB with the specified name, which he wrote in the textbox.

I tried through the script define the name of the logger, but still I can not rename the saved file, it always has the name Dataloger1.


Is there any other way than through the script to define the user name for the exported file?

BR
JohnCZ
Attachments
Výstřižek.JPG
Výstřižek.JPG (60.54 KiB) Viewed 7930 times

mark.monroe
Posts: 824
Joined: Tue Mar 13, 2012 9:53 am

Re: Rename Name of Exported Dataloger throught textbox

Post by mark.monroe »

The name is defined in the dialog box you posted. You can not change it at run time. If you want to change it, you would have to search the location where you saved the datalogger file and rename it using a script.

For example, if you saved a file called "Datalogger 1", after you export the datalogger you would need to use C# code to search that location for a file called "Datalogger 1" and change its name to what ever you want.
Best Regards,
Mark Monroe

Beijer Electronics, Inc. | Applications Engineer

JohnCZ
Posts: 73
Joined: Wed Jun 27, 2012 1:17 am
Location: CZ
Contact:

Re: Rename Name of Exported Dataloger throught textbox

Post by JohnCZ »

Thanks

I make some script and Now it works.

JohnCZ

JohnCZ
Posts: 73
Joined: Wed Jun 27, 2012 1:17 am
Location: CZ
Contact:

Re: Rename Name of Exported Dataloger throught textbox

Post by JohnCZ »

Here is that script i Used.

Code: Select all

	void Button1_Click(System.Object sender, System.EventArgs e)
		{
			string FromFile = @"\Hard Disk\DatabaseExport\Data Loggers\DataLogger1.csv";
			string Tofile = @"\hard Disk\DatabaseExport\Data Loggers\";
			try
			{
							
				File.Move(FromFile, Path.Combine(Tofile, TextBox1.Text)); // pokus o přesun
							}
			catch (IOException ex)

			{
				Console.WriteLine(ex); // pokud není soubor nebo je špatně napiš Error
			}
		
   		 }
  	 }
Attachments
Projekt1.zip
(33.64 KiB) Downloaded 652 times

Post Reply