2 Replies - 775 Views - Last Post: 05 October 2009 - 10:37 AM Rate Topic: -----

#1 DCunningham  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 41
  • Joined: 19-May 09

Variables in Virtual Paths

Posted 05 October 2009 - 09:09 AM

Hello All,

I'm still quite the programming novice, especially concerning Asp.net and I've just got a quick question...

On my webpage users will be able to upload excel spreadsheets to the database. But as it sits right now the file name of that uploaded data is hard coded. I got to thinking that if more than one person simultaneously uploads a file this would create two of the same named file, so the possibility that they would just rewrite the other's is there. :( So my thought was to somehow use a guid to overcome the trouble and just generate some very random file names so they wouldn't conflict. I've figured out how to create the guid, but now it's sending that info inside the virtual path I've created (I'm using Server.MapPath) that's got me stumped.

So is it possible to use variables within a virtual path, let alone just a simple function call to my guid generator?

Any help or insight would be greatly appreciated.

Here's a couple snippets of my code:

FileUploadExcel.SaveAs(Server.MapPath("ExcelImport.xls"))


Public Function getNewGuid() As String
	Dim g As New Guid()
	Return Guid.NewGuid().ToString()
End Function




Thanks,
DCunningham

Is This A Good Question/Topic? 0
  • +

Replies To: Variables in Virtual Paths

#2 DCunningham  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 41
  • Joined: 19-May 09

Re: Variables in Virtual Paths

Posted 05 October 2009 - 10:25 AM

Well, I don't know why I didn't think of just some simple concatenation first thing, but this is what I have now.

FileUploadExcel.SaveAs(Server.MapPath("~/ExcelImports/" & getNewGuid() & ".xls"))




No obvious syntax errors, however I can't test logically due to the server's inaccessibility.

But if anyone still would like to add something, feel free.:)

D
Was This Post Helpful? 0
  • +
  • -

#3 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1642
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: Variables in Virtual Paths

Posted 05 October 2009 - 10:37 AM

Moved to ASP.NET :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1