DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 6 of 6

Thread: How can make my program only access a particular folder for writing?

  1. #1
    Join Date
    Jan 2007
    Posts
    8

    Setting access privilages to a shared folder through coding??

    Hi,

    How do I set access privilages to a shared folder through coding and make the folder accessible only by my code....
    For ex: "Test" folder is a network share. can i make this folder accessed only by my program but not by any other user??

    Rgds,
    Prithvi
    Last edited by Prithvirajck; 04-19-2007 at 05:20 AM. Reason: Setting access privilages to a shared folder through coding??

  2. #2
    Join Date
    Nov 2003
    Location
    Alameda, CA
    Posts
    1,737
    AFAIK the permissions in Windows are set by user, not by application.
    single files can be locked by an application, but I do not know about folders.
    maybe if we give us more details there can be alternatives
    "There are two ways to write error-free programs. Only the third one works."
    Unknown

  3. #3
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    Marco is correct: you cannot grant permissions to an application, only to a user account. You could create a user account to be used only by your application. Grant the account permission to the shared folder, then use Windows API functions to have your application access the folder as that user. See http://support.microsoft.com/kb/q173011/ for more information.
    Phil Weber
    http://www.philweber.com

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

  4. #4
    Join Date
    Jan 2007
    Posts
    8
    Can guide me how single files can be locked by an application??
    For ex: take CSV file.

    Thanks & Regards,
    Prithvi
    http://www.prithvi.tk
    Last edited by Prithvirajck; 04-20-2007 at 05:45 AM.

  5. #5
    Join Date
    Nov 2003
    Location
    Alameda, CA
    Posts
    1,737
    you can use the LockFile API, but in VB I strongly do NOT recommend it, it is much better to use the locking mechanism of the Open statement
    http://msdn2.microsoft.com/en-us/lib...77(vs.60).aspx
    Use:
    Open myFile For ... Access ... Lock Read Write as #file
    and specify in the dots the way you want to open the file

    BTW your problem is very common, thus you can find a lot of third party components that allows you to crypt/decrypt entire folders, that you can open from your app with a password. But for that, I am sorry I do not have any suggestion because I never used any of them.
    "There are two ways to write error-free programs. Only the third one works."
    Unknown

  6. #6
    Join Date
    Jan 2007
    Posts
    8
    The following is the code, which ll take the first line of the "ManipulateCSV.txt" and split the words seperated by commas and pastes one by one in "strOPFile.txt".

    Code:
    Option Explicit
    Sub main()
    Dim strCurrentPath
    Dim strLine, i, LowerVal, UpperVal
    Dim Temp$
    Dim strValues
    Dim fn As Integer
    strCurrentPath = App.Path
    Temp$ = Dir(strCurrentPath & "\ManipulateCSV.txt")
    fn = FreeFile
    Do While Temp$ <> ""
        Open strCurrentPath & "\ManipulateCSV.txt" For Input Access Read Lock Read Write As #fn
            Do While Not EOF(fn)
                Line Input #fn, strLine
            Loop
        Close #fn
        strValues = Split(strLine, ",", -1, 1)
        LowerVal = LBound(strValues)
        UpperVal = UBound(strValues)
        Open strCurrentPath & "\strOpFile.txt" For Output Access Write Lock Read Write As #fn
        For i = LowerVal To UpperVal
            Write #fn, strValues(i)
        Next
        Close #fn
        Temp$ = Dir
    Loop
    End Sub
    Now I or using another program being able to manipulate the above shown txt files. Is it possible to block these txt files from being manipulated by me or another program, exept for the above code??

    Thanks & Regards,
    Prithvi

Similar Threads

  1. Replies: 1
    Last Post: 09-06-2002, 06:45 PM
  2. Replies: 1
    Last Post: 09-06-2002, 06:45 PM
  3. Access 97 to 2000 Conversion Error
    By Michelle in forum VB Classic
    Replies: 8
    Last Post: 04-19-2002, 05:01 PM
  4. Replies: 2
    Last Post: 02-09-2001, 09:24 PM
  5. How do I run Access Macros or Forms in a VB program?
    By Bruno Baker in forum VB Classic
    Replies: 0
    Last Post: 08-17-2000, 03:35 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center