Click here to Skip to main content
16,007,760 members
Home / Discussions / C#
   

C#

 
GeneralRe: Calculate Plus Minus values from TextBox Pin
OriginalGriff23-Feb-11 20:56
mveOriginalGriff23-Feb-11 20:56 
GeneralRe: Calculate Plus Minus values from TextBox Pin
Anurag Gandhi23-Feb-11 21:27
professionalAnurag Gandhi23-Feb-11 21:27 
GeneralRe: Calculate Plus Minus values from TextBox Pin
OriginalGriff23-Feb-11 23:07
mveOriginalGriff23-Feb-11 23:07 
GeneralRe: Calculate Plus Minus values from TextBox Pin
Pravin Patil, Mumbai23-Feb-11 22:31
Pravin Patil, Mumbai23-Feb-11 22:31 
QuestionLINQ to xml query Pin
faheemnadeem23-Feb-11 18:34
faheemnadeem23-Feb-11 18:34 
AnswerRe: LINQ to xml query Pin
#realJSOP24-Feb-11 4:55
professional#realJSOP24-Feb-11 4:55 
QuestionHow to display a warning message in file uploading when the uploading file is open in user machine... Pin
Rocky2323-Feb-11 18:05
Rocky2323-Feb-11 18:05 
GeneralRe: How to display a warning message in file uploading when the uploading file is open in user machine... Pin
Wayne Gaylard23-Feb-11 22:20
professionalWayne Gaylard23-Feb-11 22:20 
There is a hack using a Try Catch Block and catching an IOException . In your case you could do something like this,

private void BtnBrowse_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog file1 = new OpenFileDialog { Multiselect = false, Filter = "All Supported Files |*.txt;*.csv|Text|*.txt|CSV |*.csv" };
            if (file1.ShowDialog() == true) 
            {
                new FileInfo(file1.FileName); 
                using (Stream str = file1.OpenFile())
                {
                    try
                    {
                        System.IO.FileStream fs = System.IO.File.OpenWrite(file1.FileName);
                        fs.Close();
                    }
                    catch (IOException)
                    {
                        MessageBox.Show("Please check the file has been Closed before you upload", "Manual File Upload");
                        return;
                    }
                    TextReader reader = new StreamReader(str); 
                    reader.ReadToEnd();
                    textBox1.Text = file1.FileName;
                    textBox1.IsEnabled = false; 
                } 
            }
        }


This solution is not very elegant but it works Big Grin | :-D .The only other way I know would be to use the proper Win32 API's, which is tiresome.

Happy Coding
GeneralRe: How to display a warning message in file uploading when the uploading file is open in user machine... Pin
Rocky2323-Feb-11 22:42
Rocky2323-Feb-11 22:42 
GeneralRe: How to display a warning message in file uploading when the uploading file is open in user machine... Pin
Wayne Gaylard23-Feb-11 22:52
professionalWayne Gaylard23-Feb-11 22:52 
Questionc# Need help getting WPF window to draw behind desktop icons Pin
lanpartyes23-Feb-11 15:13
lanpartyes23-Feb-11 15:13 
AnswerRe: c# Need help getting WPF window to draw behind desktop icons Pin
SledgeHammer0123-Feb-11 18:13
SledgeHammer0123-Feb-11 18:13 
GeneralRe: c# Need help getting WPF window to draw behind desktop icons Pin
lanpartyes23-Feb-11 23:49
lanpartyes23-Feb-11 23:49 
Questionvb.net to c#.net Pin
David C# Hobbyist.23-Feb-11 14:49
professionalDavid C# Hobbyist.23-Feb-11 14:49 
AnswerRe: vb.net to c#.net Pin
RobCroll23-Feb-11 16:18
RobCroll23-Feb-11 16:18 
AnswerRe: vb.net to c#.net Pin
thatraja23-Feb-11 16:29
professionalthatraja23-Feb-11 16:29 
AnswerRe: vb.net to c#.net Pin
Pravin Patil, Mumbai23-Feb-11 23:49
Pravin Patil, Mumbai23-Feb-11 23:49 
QuestionQuestion about adding/removing account Pin
turbosupramk323-Feb-11 9:05
turbosupramk323-Feb-11 9:05 
AnswerRe: Question about adding/removing account Pin
GenJerDan23-Feb-11 9:42
GenJerDan23-Feb-11 9:42 
GeneralRe: Question about adding/removing account Pin
turbosupramk323-Feb-11 10:14
turbosupramk323-Feb-11 10:14 
GeneralRe: Question about adding/removing account Pin
GenJerDan23-Feb-11 10:38
GenJerDan23-Feb-11 10:38 
GeneralRe: Question about adding/removing account Pin
turbosupramk323-Feb-11 11:05
turbosupramk323-Feb-11 11:05 
GeneralRe: Question about adding/removing account Pin
GenJerDan23-Feb-11 11:08
GenJerDan23-Feb-11 11:08 
GeneralRe: Question about adding/removing account Pin
turbosupramk323-Feb-11 11:33
turbosupramk323-Feb-11 11:33 
GeneralRe: Question about adding/removing account Pin
GenJerDan24-Feb-11 3:33
GenJerDan24-Feb-11 3:33 

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.