# Tag Info

7

I don't have any kernels running on a remote machine so I cannot be sure of how this is handled, but I think it has as good a chance as any of working. A file that exists: MathLinkCallFrontEnd[MLFSFileByteCount["A:\\foo.txt"]] 16 A file that does not exist: MathLinkCallFrontEnd[MLFSFileByteCount["A:\\bar.txt"]] $Failed Other commands in ... 9 No need to go through all the machinations of trimming/applying a cascade of functions, simply: CurrentValue["NotebookFileName"] 11 You have to add a few extra commands to NotebookFileName to remove the directory. Last@FileNameSplit@NotebookFileName[] Hope this helps. 3 Isn't DirectoryName @$InputFileName the answer? path = FileNameJoin[{$TemporaryDirectory, "test.m"}]; Export[ path, "Print @ DirectoryName @$InputFileName", "Text" ] Get @ path (...)\Local\Temp\

0

Why not PutAppend? Something like this should give you the desired result: testData = RandomReal[{0, 1}, {1, 1}]; OpenAppend["C:\\Users\\Alex\\Desktop\\1\\file1.nb", testData]; Consult the documentation too.

1

Use SetDirectory: SetDirectory["yourdir"]

3

You are actually looking for Put. Notice that the syntax is reversed from Write. str = "myfile.txt" Put["my first stuff", str] Put["my second stuff", str] FilePrint[%] (* "my second stuff" *)

0

str = OpenWrite[] Write[str, "my first stuff"] Write[str, "my second stuff"] Close[str] FilePrint[%] "my first stuff" "my second stuff"

Top 50 recent answers are included