473,467 Members | 1,979 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Using file path links instead of document attachments

40 New Member
Hi guys.

I'm referring to the insight by Rabbit on this link: http://bytes.com/topic/data-manageme...external-media
and by jforbes on this link: http://bytes.com/topic/access/answer...i-attachements

I made a dummy database with attachments and realised attachments could take up too much space, as compared to the actual data. This inevitably would use up the 2GB provided by Access in a short time on my back-end. I need to know how to use a file path link that opens to the document in a specific location, and avoid at all costs using attachments in the database.

Secondly, in an instance where a record has multiple attachments, how can I be able to use multiple file path links on the same record instead of multiple file attachments (as is the case with Access 2007)?

Thank you.

Kind regards,

SK
Jul 8 '15 #1
3 13547
TheSmileyCoder
2,322 Recognized Expert Moderator Top Contributor
First off, note that there is a 1 major difference between a file link and an attachment. When you have an attachment, you are making a copy of the file and storing it in the database.
With a file link, you run the risk of someone outside of your control modifying/editing/moving/deleting the file.


In my application, what I do, after the user has selected the file is to copy the file to a location on the server, named by my app. I also create a record in my table, and the file is then named by the primary key. So the file path could look like:
\\MyNetworkDrive\MyAppName\Filestorage\737.StoredF ile

Now this sort of naming convention has 1 benefit. People will not be able to randomly search out the file and mess with it. Furthermore its also hidden.

Now when the user needs to restore the file, the app will copy the file from that location, into C:\MyAppName\WorkingFolder\ and then open it.

To have multiple files, the solution is to use a 1-many relationship between your record and the filetable.
Jul 8 '15 #2
zmbd
5,501 Recognized Expert Moderator Expert
I do basically the same as TheSmileyCoder; however, I don't rename.... something I'll be doing in the future!
Jul 8 '15 #3
jforbes
1,107 Recognized Expert Top Contributor
I like the option of obfuscating the filename in TheSmileyCoders scenario. For attachments that should be indelible, this is a great idea.

In our environment we have two types of Attachments. Live Documents and Reference Documents. The Live Documents are to be edited as part of the daily workflow, where the Reference Documents are to be viewed only. (I might have to rework the Reference Documents to be stored off the way TheSmilyCoder does...) The two types of documents enter the system differently. The Live Documents get the FilePath to the original file saved off, where the Reference Documents are first copied to an Attachements Folder on the Server, while stripping out SQL reserved characters and then the FilePath is saved into the database. Then going forward, they are launched the same.

To launch the Attachment... to edit or view gets complicated by what programs are used to edit and by our network topology which crosses a few hundred miles, but the basics to launch an attachment are in the mocked up code below:

Expand|Select|Wrap|Line Numbers
  1. Function OpenAttachment(ByVal sTargetAndLocation As String) As Boolean
  2.  
  3.     Dim dTaskID As Double    
  4.     OpenAttachment = False
  5.  
  6.     If InStr(sTargetAndLocation, "http") > 0 Then
  7.         ' Open hyperlink
  8.         FollowHyperlink (sTargetAndLocation)
  9.         OpenAttachment = True
  10.     Else
  11.         ' Open with Shell
  12.         If fileExists(sTargetAndLocation) Then dTaskID = Shell("explorer.exe "
  13. & sTargetAndLocation, vbNormalFocus)
  14.         OpenAttachment = (dTaskID >= 0)
  15.     End If
  16.  
  17. End Function
  18.  
  19. Function fileExists(ByVal strFile As String, Optional bFindFolders As Boolean) As Boolean
  20.     'Purpose:   Return True if the file exists, even if it is hidden.
  21.     'Arguments: strFile: File name to look for. Current directory searched if no path included.
  22.     '           bFindFolders. If strFile is a folder, FileExists() returns False unless this argument is True.
  23.     'Note:      Does not look inside subdirectories for the file.
  24.     'Author:    Allen Browne. http://allenbrowne.com June, 2006.
  25.     Dim lngAttributes As Long
  26.  
  27.     'Include read-only files, hidden files, system files.
  28.     lngAttributes = (vbReadOnly Or vbHidden Or vbSystem)
  29.  
  30.     If bFindFolders Then
  31.         lngAttributes = (lngAttributes Or vbDirectory) 'Include folders as well.
  32.     Else
  33.         'Strip any trailing slash, so Dir does not look inside the folder.
  34.         Do While Right$(strFile, 1) = "\"
  35.             strFile = Left$(strFile, Len(strFile) - 1)
  36.         Loop
  37.     End If
  38.  
  39.     'If Dir() returns something, the file exists.
  40.     On Error Resume Next
  41.     fileExists = (Len(Dir(strFile, lngAttributes)) > 0)
  42. End Function
There are a couple schools of thought on how to open a URL. One is to send it to the Windows Shell, the other is to use FollowHyperlink. They both have their merits. As you can see, I open anything with "HTTP" in it with FollowHyperlink and everything else gets opened through a Shell. This seems to work best for us, you might want to experiment. While your experimenting, you might want to look at http://allenbrowne.com/func-GoHyperlink.html.
Jul 8 '15 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: David Webb | last post by:
The problem started when the Working Folder for a project was somehow set to the folder of another project. I set the correct working folder in VSS and deleted the .vbproj files that had been...
2
by: M. Garcia | last post by:
Good day, I created a form where one of its controls stores the hyperlink to a Word document. The form has a command button that opens the folder where the Word documents are kept using a...
0
by: Nicola George | last post by:
Hi all, I hope someone can help me as I'm going a bit metal with this problem. I have a project in ASP.NET, within this project I have Crystal Report called Catalogue. On an asp page I have a...
5
by: Sakharam Phapale | last post by:
Hi All, I am using an API function, which takes file path as an input. When file path contains special characters (@,#,$,%,&,^, etc), API function gives an error as "Unable to open input file"....
2
by: Sridhar | last post by:
Hi, I have a web form where it has a <input type=file id=file1> control. I have an Upload button to upload the file. WHen I click on browse and select one file, it is showing the full file path...
3
by: Vibhu | last post by:
Hello All, I have a input box on the HTML page with the type set to file. What I want is that when the value changes in the file textbox, it should give me the full file path. I have even tried...
2
by: BASSPU03 | last post by:
I used the Common Dialog API to store file paths on my form's underlying table. These paths are displayed in a textbox that I can click to open the selected file. Having stored the file paths in...
2
by: mpalomas | last post by:
Hi C++ folks, I have trouble to open files whose path contains non-ascii characters with std::ifstream. For instance let's say i just have a file which has Japanese characters either in the...
3
by: Carlos Avrard | last post by:
Working with a simple directory/file tree display solution (http://abeautifulsite.net/blog/2007/06/php-file-tree/) I'm able to get the page to display properly, javascript works just fine as well,...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.