Click here to Skip to main content
15,904,951 members
Home / Discussions / C#
   

C#

 
AnswerRe: save bitmap in C# Pin
OriginalGriff10-Dec-12 1:26
mveOriginalGriff10-Dec-12 1:26 
QuestionC# Pin
Half Blood Prince9-Dec-12 22:32
Half Blood Prince9-Dec-12 22:32 
AnswerRe: C# Pin
J4amieC9-Dec-12 23:03
J4amieC9-Dec-12 23:03 
AnswerRe: C# Pin
Keith Barrow9-Dec-12 23:35
professionalKeith Barrow9-Dec-12 23:35 
AnswerRe: C# Pin
Dave Kreskowiak10-Dec-12 2:19
mveDave Kreskowiak10-Dec-12 2:19 
AnswerRe: C# Pin
Abhinav S10-Dec-12 19:57
Abhinav S10-Dec-12 19:57 
Questionhi Pin
vijayalakshmi h9-Dec-12 22:30
vijayalakshmi h9-Dec-12 22:30 
AnswerRe: hi Pin
Pete O'Hanlon9-Dec-12 22:35
mvePete O'Hanlon9-Dec-12 22:35 
AnswerRe: hi Pin
J4amieC9-Dec-12 23:02
J4amieC9-Dec-12 23:02 
GeneralRe: hi Pin
Jibesh10-Dec-12 8:56
professionalJibesh10-Dec-12 8:56 
AnswerRe: hi Pin
Keith Barrow9-Dec-12 23:36
professionalKeith Barrow9-Dec-12 23:36 
AnswerRe: hi Pin
V.10-Dec-12 1:37
professionalV.10-Dec-12 1:37 
GeneralRe: hi Pin
Dave Kreskowiak10-Dec-12 2:18
mveDave Kreskowiak10-Dec-12 2:18 
AnswerRe: hi Pin
Abhinav S10-Dec-12 19:57
Abhinav S10-Dec-12 19:57 
Questionhi Pin
Sowmiya ravi9-Dec-12 22:22
Sowmiya ravi9-Dec-12 22:22 
AnswerRe: hi Pin
J4amieC9-Dec-12 23:02
J4amieC9-Dec-12 23:02 
AnswerRe: hi Pin
Keith Barrow9-Dec-12 23:37
professionalKeith Barrow9-Dec-12 23:37 
Questionasp.net and c# login and register page Pin
Member 80648029-Dec-12 21:46
Member 80648029-Dec-12 21:46 
AnswerRe: asp.net and c# login and register page Pin
Vaibhav Kharejoshi9-Dec-12 22:35
Vaibhav Kharejoshi9-Dec-12 22:35 
Questionthe use of Lambda and action delegate Pin
Tridip Bhattacharjee9-Dec-12 21:17
professionalTridip Bhattacharjee9-Dec-12 21:17 
AnswerRe: the use of Lambda and action delegate Pin
Eddy Vluggen9-Dec-12 23:04
professionalEddy Vluggen9-Dec-12 23:04 
AnswerRe: the use of Lambda and action delegate Pin
Freak309-Dec-12 23:11
Freak309-Dec-12 23:11 
QuestionI thought understood file io Pin
David C# Hobbyist.9-Dec-12 10:10
professionalDavid C# Hobbyist.9-Dec-12 10:10 
Hi I am working on file io and am getting an io exception the process cannot access the file it's in use by another process.

I tried to closed all streams. I'm baffled please help.

Here is my code:
DateTime dt = DateTime.Now.Date;
            try
            {
                string fileLocation = "C:\\pprdate.txt";
                FileStream fs = null;
                if (!File.Exists( fileLocation ))
                {
                    using (fs = File.Create( fileLocation ))
                    {
                        fs.Close();
                        fs = null;
                    }
                }
                
                string line = null;
                TextReader readFile = new StreamReader(fileLocation);
                while (true)
                {
                    
                    line = readFile.ReadLine();
                    if (line != null)
                    {
                        DateTime sd = DateTime.Parse( line );
                        if (dt >= sd.AddDays( 16 ))
                        {
                            sd = sd.AddDays( 30 );
                            StartDate.Text = sd.ToShortDateString();
                            EndDate.Text = sd.AddDays( 30 ).ToShortDateString();
                        }
                    readFile.Close();
                    readFile = null;
                    }
                    else
                    {
                        // this is where the exception happens
                        TextWriter writeFile = new StreamWriter(fileLocation);
                        DateTime sd = dt.AddDays( 7 );
                        writeFile.WriteLine( sd );
                        StartDate.Text = sd.ToShortDateString();
                        EndDate.Text = sd.AddDays( 30 ).ToShortDateString();
                        writeFile.Close();
                        writeFile = null;
                    }
                }

Frazzle the name say's it all

Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.
John F. Woods

AnswerRe: I thought understood file io Pin
Wendelius9-Dec-12 10:29
mentorWendelius9-Dec-12 10:29 
AnswerRe: I thought understood file io Pin
Dave Kreskowiak9-Dec-12 12:23
mveDave Kreskowiak9-Dec-12 12:23 

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.