Files in ASP.NET 2.0

S

shapper

Hello,

In my ASP.NET 2.0 web site I need to upload many files to various
folders and add the information in an SQL 2005 database.

I am creating a documents table which includes the fields:
[DocumentId], [DocumentAuthor] and [DocumentUrl]

This table will have records for many files.

Is there a standard way to name the files?
Maybe renaming the files to "doc" + DocumentId?
However my DocumentId is a Guid so it would be to big ... I think.
I would need to create the record, get the DocumentId and then access
the record again to add the DocumentUrl after renaming the file in
my .NET code.

Anyway, is there a standard way to make sure that every file name is
unique and that at the same time won't have an unreadable name?

Thanks,
Miguel
 
M

Milsnips

Hi Miguel,

you could do a check, something like this:

if (!System.IO.File.Exists(Request.MapPath("~/myfolder/filename")
{
//the filename was not found
}
else
{
//duplicate filename was found, create another filename
}

regards,
Pal
 
C

clintonG

Consider a hybrid filename which is comprised of four parts;

* readable text that conveys meaning
* the dot delineator ( . )
* the GUID
* the filetype extension

// example
FirstFloor_NorthElevation.627758DC-816D-4221-94AC-823C47D89914.dwg

Then write a "helper class" to parse filenames, remove the GUID and
reassemble the filename into readable text when people need to read the
filename in a page. I would use the dot (.) as a delineator.

// parsed example used to build references in a page
<a href="FirstFloor_NorthElevation.627758DC-816D-4221-94AC-823C47D89914.dwg"
title="FirstFloor_NorthElevation">
FirstFloor_NorthElevation
</a>

And remember, a "standard" is what you make it :)

<%= Clinton Gallagher
NET csgallagher AT metromilwaukee.com
URL http://clintongallagher.metromilwaukee.com/
MAP http://wikimapia.org/#y=43038073&x=-88043838&z=17&l=0&m=h
 
T

Thomas Hansen

Hello,

In my ASP.NET 2.0 web site I need to upload many files to various
folders and add the information in an SQL 2005 database.

Why don't you consider storing the files in a database...??
Many people tend to look at that as a "standard"... ;)
Data == DataBase
Code == Application...

..t
 
S

shapper

Why don't you consider storing the files in a database...??
Many people tend to look at that as a "standard"... ;)
Data == DataBase
Code == Application...

.t

--http://ajaxwidgets.com
Free ASP.NET Ajax Widgets NOW!

Storing the files in the database is an option.
I posted a message in a few SQL forums and most people said not to do
it ...

Anyway, I still didn't decided anything.

Any comments?

Thanks,
Miguel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,152
Latest member
LorettaGur
Top