Setting path to root of USB drive

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • snappX
    Forum Member
    • May 2008
    • 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?
  • Mick
    No longer a forum member
    • Feb 2012
    • 173

    #2
    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

    Comment

    • snappX
      Forum Member
      • May 2008
      • 2

      #3
      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.

      Comment

      • longedge
        Indigo Rose Customer
        • Aug 2003
        • 2498

        #4
        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, 03:29 AM.

        Comment

        Working...
        X