Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
use relative path in script
#2
C# code:
// script "" /*/ ifRunning warn_restart; r Libraries\libxl\libxl.net.dll; /*/ //.
using Au; using System;
using libxl;
partial class Script : AScript { [STAThread] static void Main(string[] a) => new Script(a); Script(string[] args) { //;;;
 
System.IO.Directory.SetCurrentDirectory(ScriptFolder());
Book book = new BinBook();
var s = "example.xls";
book.load(s);
Sheet sheet = book.getSheet(0);
double d = sheet.readNum(3, 1);
sheet.writeNum(3, 1, d * 2);
sheet.writeStr(4, 1, "new string");
var s2 = "example_ok.xls";
book.save(s2);
}

/// <summary>
/// Gets folder path of caller's C# source file.
/// </summary>
/// <param name="f">Don't use.</param>
public static string ScriptFolder([System.Runtime.CompilerServices.CallerFilePath] string f = null) => APath.GetDirectory(f);
}

Don't need to add to resources.


Messages In This Thread
use relative path in script - by macman - 01-12-2021, 10:41 AM
RE: use relative path in script - by Gintaras - 01-12-2021, 11:46 AM
RE: use relative path in script - by macman - 01-13-2021, 06:24 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)