View Single Post
Old 05-31-2009, 07:33 AM   #1 (permalink)
Meydanb
Registered User
 
Join Date: May 2008
Posts: 6
OS: winXP SP2 (switching to linux)


C# Error while trying to create text file

hey, i dont know if this is the right forum, so sorry if its not.

so im doing this project for school, im doing a Check Mate Game and im having a problem:
when im trying to create a Text File im getting this error:
Quote:
Access to the path 'D:\Projects\Meydan\Chess\Saves' is denied.
this is the code:
Code:
public void WriteToFile()
        **

            SW = File.CreateText("D:\\Projects\\Meydan\\Chess\\Saves");
            for (int i = 0; i < 8; i++)
            **
                for (int j = 0; j < 8; j++)
                **
                    SW.WriteLine("Index_i"); // המיקום במערך של המשבצת
                    SW.WriteLine(i.ToString());
                    SW.WriteLine("Index_j"); // המיקום במערך של המשבצת
                    SW.WriteLine(j.ToString());
                    //-------------------------------------------------
                    SW.WriteLine("Empty"); // סימון שאומר שמתחת לשורה זו יהיה הערך של האם המשבצת ריקה
                    SW.WriteLine(bord[i, j].GetIsEmpty().ToString());
                    //-------------------------------------------------
                    SW.WriteLine("Type"); // סוג החייל, אם אין חייל בכל השורות אשר מתקשרות לחייל יהיה רשום 0
                    if (bord[i, j].GetIsEmpty())
                        SW.WriteLine("0");
                    else
                        SW.WriteLine(bord[i, j].GetPiece().Gettype());
                    //------------------------------------------------
                    SW.WriteLine("Path");// הכתובת של השתמונה של החייל
                    if (bord[i, j].GetIsEmpty())
                        SW.WriteLine("0");
                    else
                        SW.WriteLine(bord[i, j].GetPiece().GetPath());
                    //-------------------------------------------------
                    SW.WriteLine("First"); // האם התזוזה הראשונה
                    if (bord[i, j].GetIsEmpty())
                        SW.WriteLine("0");
                    else
                        SW.WriteLine(bord[i, j].GetPiece().Getfirst().ToString());
                    //-----------------------------------------------------------
                    SW.WriteLine("Color"); // צבע החייל, כלומר איזה צד- שחורים או לבנים
                    if (bord[i, j].GetIsEmpty())
                        SW.WriteLine("0");
                    else
                    **
                        if (bord[i, j].GetPiece().GetWhite())
                            SW.WriteLine("White");
                        else
                            SW.WriteLine("Black");
                    }
                    //---------------------------------------
                    SW.WriteLine("From_i"); // האינדקס של המקום האחרון שהחייל שנמצא על המשבצת היה בו, אם אין חייל יהיה 0
                    if (bord[i, j].GetIsEmpty())
                        SW.WriteLine("0");
                    else
                        SW.WriteLine(bord[i, j].GetFrom().X.ToString());

                    SW.WriteLine("From_j"); // האינדקס של המקום האחרון שהחייל שנמצא על המשבצת היה בו, אם אין חייל יהיה 0
                    if (bord[i, j].GetIsEmpty())
                        SW.WriteLine("0");
                    else
                        SW.WriteLine(bord[i, j].GetFrom().Y.ToString());
                    //----------------------------------------------------
                    SW.WriteLine("End"); //סימון שהמשבצת הראשונה הסתיימה ומעבר למשבצת הבאה
                }
            }

            SW.Close();
sorry for the comments in jibrish, its hebrew so youl probably wont understand them.

i tried giving premmisions to everyone in that folder, didnt work, plz help me, i need to start getting close to finishing this project or i wont get a grade on it.
thanks.

Last edited by Meydanb; 05-31-2009 at 07:34 AM.
Meydanb is offline   Reply With Quote
Important Information
Join the #1 Tech Support Forum Today - It's Totally Free!

TechSupportForum.com is a leading support website for your computer needs. We offer free, friendly and personalized computer support. Why pay to have your computer fixed when you can do it for free.

Join TechSupportforum.com Today - Click Here