Options

Code to "wake up" a mapped HDD on a server

VotucVotuc Member Posts: 206
edited 2010-10-28 in NAV Three Tier
I am trying to display a PDF file on a client computer through the RTC from a mapped drive on the server computer.

I am using HYPERLINK() which works sometimes and other times does not. I believe this is because the mapped folder is not ready to be accessed fast enough.

What could I do to force the mapped hard drive to be ready (perhaps save over a file each time?) then perhaps a <timer> function to wait 5 seconds or so to make sure it is ready before the HYPERLINK function? :-k

Comments

  • Options
    SavatageSavatage Member Posts: 7,142
    Votuc wrote:
    I am using HYPERLINK() which works sometimes and other times does not. I believe this is because the mapped folder is not ready to be accessed fast enough.

    I don't believe it has to do with it accessing it fast enough.
    Do you receive an error message?
    If it doesn't open - go to My Computer & see if it says "Network Drive" or "Discontected Network Drive".
    If it's disconnected you need to double click on it to reconnect.

    I believe on your server, does it have file server role?, that you can set a setting on shared drives that does or does not disconnect login users depending on what you want. Or you can set a time limit.
  • Options
    bbrownbbrown Member Posts: 3,268
    Can't you use UNC paths? Which eliminate the whole mapped drive problem.
    There are no bugs - only undocumented features.
  • Options
    VotucVotuc Member Posts: 206
    bbrown wrote:
    Can't you use UNC paths? Which eliminate the whole mapped drive problem.

    I am not sure how to do that. I see an example of FILE.OPEN in the Help files:

    Variable: TestFile
    Data type: File



    TestFile.TEXTMODE(TRUE);
    TestFile.WRITEMODE(FALSE);
    TestFile.OPEN('C:\temp\simple.xml');

    How do I alter this to display a PDF? I tried simply changing the file path to my PDF file and I got an I/O error.
  • Options
    bbrownbbrown Member Posts: 3,268
    UNC (Universal Naming Convention) paths are presented in the format \\sharename\folder. An example might be \\fileshare\datafolder.

    In your example you would define a text variable, assign the UNC path to it, and pass it to the create call.

    Variable: TestFile
    Data type: File

    Variable: FilePath
    Data Type: Text (100)

    FilePath := '\\fileshare\datafolder\simple.xml'
    TestFile.TEXTMODE(TRUE);
    TestFile.WRITEMODE(FALSE);
    TestFile.OPEN(FilePath);

    of course you need to specify a valid UNC path for your network. You can use Network Neighborhood to browse and then copy and paste the path
    There are no bugs - only undocumented features.
  • Options
    Luc_VanDyckLuc_VanDyck Member, Moderator, Administrator Posts: 3,633
    Votuc wrote:
    bbrown wrote:
    How do I alter this to display a PDF? I tried simply changing the file path to my PDF file and I got an I/O error.
    If you want the file to be opened in the default application, then you'll have to use the HYPERLINK-function like this:
    HYPERLINK('\\fileshare\datafolder\simple.pdf');
    
    No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)
Sign In or Register to comment.