Indigo Rose Software

Professional Software Development Tools

 
+ Reply to Thread
Results 1 to 4 of 4
  1. #1
    Join Date
    May 2008
    Posts
    2

    Setting path to root of USB drive

    I am trying to find if a file exits in the root of the USB drive:
    Code:
    Folder.SetCurrent(_SourceDrive);
    new_exist = File.DoesExist("new.ini");
    if new_exist then 
        Dialog.Message("Stop! There is a file already with this name", "You cannot write a file");
    else
        Dialog.Message("Are you sure you want to write this file?", "You are about to write a file");
    end
    The problem I am facing is that navigating to the root of the USB drive (eg: F\:) when my AMS 8 application is installed in a sub-folder (eg: F:\NewApplication\) does not work with the _SourceDrive variable. According to the AMS destructions - sorry, instructions - _SourceDrive
    The drive that the AutoPlay application was run from (e.g. "C:" or "D:")

    While _SourceFolder
    The full path to the folder that the AutoPlay application was run from (e.g. "C:\Downloads" or "D:").

    In my example above, the script fails to find new.ini in the drive root, but finds it in the sub folder. Thus _SourceFolder and _SourceDrive do the same thing. Is this a USB drive issue?
    I have tried setting the path ..\\_SourceDrive but that fails with an error, naturally enough.

    How can I set a path below the folder the application is installed in?

  2. #2
    Mick is offline No longer a forum member
    Join Date
    Feb 2012
    Posts
    173
    Code:
    Locationt = Folder.Find(_SourceFolder, "Data", false, nil);
    Locations = Table.Concat(Locationt, "", 1, TABLE_ALL);
    Drives = String.Left(Locations, 2);
    result = Dialog.Message("Notice", "" ..Drives.. "", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
    that returns "C:", "data" is a folder in my autoplay root, you could use plugins or whateever

  3. #3
    Join Date
    May 2008
    Posts
    2
    Quote Originally Posted by Mick View Post
    Code:
    Locationt = Folder.Find(_SourceFolder, "Data", false, nil);
    Locations = Table.Concat(Locationt, "", 1, TABLE_ALL);
    Drives = String.Left(Locations, 2);
    result = Dialog.Message("Notice", "" ..Drives.. "", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
    that returns "C:", "data" is a folder in my autoplay root, you could use plugins or whateever
    I'm going to need more help pointers with your code snippet. Whatever I change the folder find "folder" value to, the script errors out with On Click, Line 2: Argument 1 must be of type table.

    As I said, it's running from a USB drive with a non-fixed drive letter. I simply (well, it's simple to do it in DOS) want to set the 'current folder' to the root of the drive.

  4. #4
    Join Date
    Aug 2003
    Posts
    2,466
    Are you building your application to an .exe or to a folder structure?

    If it's an exe then you need to use the _CommandLineArgs to get the drive e.g.

    Code:
    swhere = String.Left(String.Replace(_CommandLineArgs[1], "SFXSOURCE:", "", true), 2);
    would give you the drive that the exe is running from.
    Last edited by longedge; 03-31-2012 at 03:29 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts