Click here to Skip to main content
15,889,462 members
Home / Discussions / C#
   

C#

 
GeneralRe: Free Form Controls Pin
Jon G28-Apr-04 10:14
Jon G28-Apr-04 10:14 
GeneralRe: Free Form Controls Pin
Heath Stewart28-Apr-04 10:15
protectorHeath Stewart28-Apr-04 10:15 
GeneralRe: Free Form Controls Pin
..Hubert..28-Apr-04 22:17
..Hubert..28-Apr-04 22:17 
GeneralRE: Web Service Startup Pin
mjmcinto28-Apr-04 9:12
mjmcinto28-Apr-04 9:12 
GeneralRe: RE: Web Service Startup Pin
Jesse Squire28-Apr-04 9:46
Jesse Squire28-Apr-04 9:46 
GeneralRe: RE: Web Service Startup Pin
mjmcinto28-Apr-04 10:39
mjmcinto28-Apr-04 10:39 
GeneralRe: RE: Web Service Startup Pin
Heath Stewart28-Apr-04 11:19
protectorHeath Stewart28-Apr-04 11:19 
GeneralRe: RE: Web Service Startup Pin
je_gonzalez28-Apr-04 11:03
je_gonzalez28-Apr-04 11:03 
Your question is not clear as you use "each instance" and yet you seem to want to have a global value. If what you are trying to accomplish is to save yourself from having to re-read a semi-static file, here is what I would try...

// THE RESULTANT DATA
object myData = null;

// THE NAME OF THE FILE
string myFileName = @Server.MapPath(@"\dir\filename");

// GET THE INFO
System.IO.FileInfo fileInfo = new System.IO.FileInfo(myFileName);

// DOES IT EXIST
if (fileInfo.Exists)
{
// THE NAME OF THE DATA KEY
string myDataKey = "DATA";

// THE NAME OF THE TIMESTAMP KEY
string myTimestampKey = "DATETIME";

// GET THE PREVIOUS TIME STAMP (IF ANY, ELSE A NULL)
DateTime myTimestamp = Application[myTimestampKey] as DateTime;

// GET THE TIMESTAMP
DateTime currentTimestamp = fileInfo.LastWriteTime;

// GET THE PREVIOUS DATA (IF ANY, ELSE A NULL)
myData = Application[myKey];

// ANY PREVIOUS DATA?
if (myData != null)
{
// DO WE HAVE A TIMESTAMP?
if (myTimestamp == null)
{
// SHOULD NOT HAPPEN, BUT JUST IN CASE (DATA AND NO TIMESTAMP)
myData = null;
}
else
{
// SAME?
if (!myTimestamp.Equals(currentTimestamp))
{
// FILE CHANGED, RE-READ
myData = null;
}
}
}

// ALREADY THERE?
if (myData == null)
{
// GET THE DATA
myData = ...;

// AND SAVE FOR NEXT TIME
Application[myDataKey] = myData;

// AND SAVE THE TIMESTAMP
Application[myTimestampKey] = currentTimestamp;
}
}


Have fun.....
GeneralRe: RE: Web Service Startup Pin
mjmcinto28-Apr-04 11:25
mjmcinto28-Apr-04 11:25 
GeneralRe: RE: Web Service Startup Pin
mjmcinto29-Apr-04 4:00
mjmcinto29-Apr-04 4:00 
QuestionHow can I change (Windows form) ListView item height? Pin
Arnaud Bui28-Apr-04 7:09
Arnaud Bui28-Apr-04 7:09 
AnswerRe: How can I change (Windows form) ListView item height? Pin
Heath Stewart28-Apr-04 8:25
protectorHeath Stewart28-Apr-04 8:25 
GeneralQuestion on TabControl and context menu Pin
Flack28-Apr-04 6:57
Flack28-Apr-04 6:57 
GeneralRe: Question on TabControl and context menu Pin
Heath Stewart28-Apr-04 8:17
protectorHeath Stewart28-Apr-04 8:17 
Generallive video Pin
Anonymous28-Apr-04 6:46
Anonymous28-Apr-04 6:46 
GeneralRe: live video Pin
Heath Stewart28-Apr-04 8:14
protectorHeath Stewart28-Apr-04 8:14 
GeneralRe: live video Pin
Anonymous29-May-04 8:16
Anonymous29-May-04 8:16 
Generalremoting : singleton vs singlecall Pin
Anonymous28-Apr-04 5:57
Anonymous28-Apr-04 5:57 
GeneralRe: remoting : singleton vs singlecall Pin
Heath Stewart28-Apr-04 6:27
protectorHeath Stewart28-Apr-04 6:27 
Questionhow do i loop controls on webpage Pin
robmays28-Apr-04 5:25
robmays28-Apr-04 5:25 
AnswerRe: how do i loop controls on webpage Pin
Heath Stewart28-Apr-04 6:25
protectorHeath Stewart28-Apr-04 6:25 
GeneralRe: how do i loop controls on webpage Pin
robmays28-Apr-04 8:15
robmays28-Apr-04 8:15 
GeneralSplitted forms and selection Pin
Gian28-Apr-04 5:17
Gian28-Apr-04 5:17 
GeneralRe: Splitted forms and selection Pin
Heath Stewart28-Apr-04 6:24
protectorHeath Stewart28-Apr-04 6:24 
GeneralListView with sub-lists Pin
Jon G28-Apr-04 4:54
Jon G28-Apr-04 4:54 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.