Tag Info

New answers tagged


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: MathLink`CallFrontEnd[MLFS`FileByteCount["A:\\foo.txt"]] 16 A file that does not exist: MathLink`CallFrontEnd[MLFS`FileByteCount["A:\\bar.txt"]] $Failed Other commands in ...


No need to go through all the machinations of trimming/applying a cascade of functions, simply: CurrentValue["NotebookFileName"]


You have to add a few extra commands to NotebookFileName to remove the directory. Last@FileNameSplit@NotebookFileName[] Hope this helps.


Isn't DirectoryName @ $InputFileName the answer? path = FileNameJoin[{$TemporaryDirectory, "test.m"}]; Export[ path, "Print @ DirectoryName @ $InputFileName", "Text" ] Get @ path (...)\Local\Temp\


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.


Use SetDirectory: SetDirectory["yourdir"]


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" *)


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