| | |
Date/Time Stamped and Numbered filenames when saving to jpeg?
Please support our VB.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Oct 2009
Posts: 1
Reputation:
Solved Threads: 0
Right now the existing VB code I have uses GUID to generate "random" filenames on save.
For instance:
ff8514d389a041649fd8b925a32f2b51.jpg
e1c938560fc1464ab2138065fc4661d3.jpg
Instead I want a date stamp and numbered filename:
for instance:
20091015_131644_001.jpg <--(Date_Time_NumberIncrement)
20091015_131551_002.jpg
Or something along those lines...
The current code (which saves a jpeg to a random GUID filename) is below:
For instance:
ff8514d389a041649fd8b925a32f2b51.jpg
e1c938560fc1464ab2138065fc4661d3.jpg
Instead I want a date stamp and numbered filename:
for instance:
20091015_131644_001.jpg <--(Date_Time_NumberIncrement)
20091015_131551_002.jpg
Or something along those lines...
The current code (which saves a jpeg to a random GUID filename) is below:
VB.NET Syntax (Toggle Plain Text)
Imports System.Web Imports System.Web.Services Imports System.Web.Services.Protocols Imports System.IO ' To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. ' <System.Web.Script.Services.ScriptService()> _ <WebService(Namespace:="http://tempuri.org/")> _ <WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _ <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _ Public Class Service Inherits System.Web.Services.WebService <WebMethod()> _ Public Function SaveJPEG(ByVal strJPEG As String) As String 'saves an uploaded photo and returns a unique name reference Dim BinaryContent As Byte() = Convert.FromBase64String(strJPEG) Try 'generate a unique name (GUID) for the filename Dim strFileName As String = System.Guid.NewGuid.ToString("n") ' Dim fStream As New FileStream("D:\photos\" + strFileName + ".jpg", FileMode.CreateNew) Dim bw As New BinaryWriter(fStream) bw.Write(BinaryContent) bw.Close() fStream.Close() 'return the filename for use in Flash Return strFileName Catch ex As Exception Return ex.Message End Try End Function End Class
![]() |
Similar Threads
- Date/Time from DB (C#)
- Error in saving Date/Time in MS Access (C#)
- Code Snippet: Checking on Date and Time (C#) (C#)
- how to Minimize application to Task bar/near date/time ? (Visual Basic 4 / 5 / 6)
- Setting system date and time using c++ (C++)
- Date and Time Picker (Windows NT / 2000 / XP)
- recording date and time a link is clicked (ASP.NET)
Other Threads in the VB.NET Forum
- Previous Thread: Checkbox in Datagridview
- Next Thread: rotating Picture and Information Display
| Thread Tools | Search this Thread |
Tag cloud for VB.NET
.net .net2008 2008 access advanced application array basic beginner browser button buttons center click client code combo convert cuesent data database datagrid datagridview date datetimepicker designer dissertation dissertations dissertationtopic eclipse excel exists fade filter forms function html images input lib listview map mobile module monitor msaccess net number objects open panel pdf picturebox picturebox2 port position print printing problem read regex remove right-to-left save search serial settings shutdown socket sorting sqldatbase sqlserver survey temperature textbox timer timespan transparency txttoxmlconverter user usercontol validation vb vb.net vb2008 vba vbnet visual visualbasic visualbasic.net visualstudio.net visualstudio2008 web webbrowser winforms winsock wpf wrapingcode xml year





