Author |
Message |
tcsoccerman Server Help Squatter
Age:32 Gender: Joined: Jan 15 2007 Posts: 694 Location: Atlantis Offline
|
Posted: Sat Jun 09, 2007 5:16 pm Post subject: |
|
|
|
|
Thank you for that cyan, but as i look farther into this problem, the more sloppy i see my solution. i then thought of another solution, of not looking to variables for a players name, goals, assists, age, etc., but instead look to a text file. that's how i do my teamdata right now. let me know if this would be a better solution. otherwise, i would have to make a struct/andor method and or class for every player. . ty for any suggestoins. |
|
Back to top |
|
|
baseball43v3r Seasoned Helper
Joined: Jan 02 2006 Posts: 102 Offline
|
|
Back to top |
|
|
tcsoccerman Server Help Squatter
Age:32 Gender: Joined: Jan 15 2007 Posts: 694 Location: Atlantis Offline
|
Posted: Sun Jun 10, 2007 2:53 pm Post subject: |
|
|
|
|
Not really, you're arrows are messed up i think.... I've decided that's what i'll do though anyways. I'll start on it and let you know what i run into. |
|
Back to top |
|
|
tcsoccerman Server Help Squatter
Age:32 Gender: Joined: Jan 15 2007 Posts: 694 Location: Atlantis Offline
|
Posted: Sun Jun 10, 2007 4:27 pm Post subject: |
|
|
|
|
I'm getting a buggy error right now:
The process cannot access the file 'C:\Program Files\Team Tracker\ Logo' because it is being used by another process.
|
I realize what it means, but i can't seem to figure out the problem. This is happening when i change photos of either the team photo, or the player photo. I use the same variables for each form, since they are in different classes. that way i could copy+paste. Here is the team photo's "picdialogbox2ok" code:
void OpenpicDialog2FileOk(object sender, System.ComponentModel.CancelEventArgs e)
{
source = openpicDialog2.FileName;
Stream openbmp =openpicDialog2.OpenFile();
StreamReader openerbmp = new StreamReader(openbmp);
openpicDialog2.Dispose();
teamlogopicturebox.Image = new Bitmap(source);
if (File.Exists(destination+lblteamname.Text+" Logo"))
{
File.Delete(destination+lblteamname.Text+" Logo");
}
System.IO.File.Copy(source, destination+lblteamname.Text+" Logo");
photologo = destination+lblteamname.Text+" Logo";
teamlogopicturebox.Image = new Bitmap(source);
} |
and....the one for the player is the same, so i won't post that too. by the way, this is the only error i'm recieving. ty.
Last edited by tcsoccerman on Sun Jun 10, 2007 5:22 pm, edited 1 time in total |
|
Back to top |
|
|
tcsoccerman Server Help Squatter
Age:32 Gender: Joined: Jan 15 2007 Posts: 694 Location: Atlantis Offline
|
Posted: Sun Jun 10, 2007 4:32 pm Post subject: |
|
|
|
|
I have more info, i realize that when an actual file isn't opened, and i'm just randomly changing the photo, it works w/ out an error. Then, i open a file(which has a photopath in it's text) and change the files photo, and then get an error. hope this helps. it helps me....
I also found out it's the File.Delete part that is throwing the error. |
|
Back to top |
|
|
Cyan~Fire I'll count you!
Age:36 Gender: Joined: Jul 14 2003 Posts: 4608 Location: A Dream Offline
|
Posted: Tue Jun 12, 2007 9:20 pm Post subject: |
|
|
|
|
That's an awfully strange path, does the file even exist? If it does, you're probably opening it somewhere and not closing it.
This is the best way of closing a file when you're done with it, as the system will destroy the StreamReader right after the using block:
using (StreamReader foo = new StreamReader("file.txt"))
{
string yayForLotsOfPointlessHeapAllocations = foo.ReadLine();
} |
Another way of doing the same thing would be:
StreamReader foo = new StreamReader("file.txt");
string yayForLotsOfPointlessHeapAllocations = foo.ReadLine();
foo.Close(); |
but the first one is the recommended method. _________________ This help is informational only. No representation is made or warranty given as to its content. User assumes all risk of use. Cyan~Fire assumes no responsibility for any loss or delay resulting from such use.
Wise men STILL seek Him. |
|
Back to top |
|
|
tcsoccerman Server Help Squatter
Age:32 Gender: Joined: Jan 15 2007 Posts: 694 Location: Atlantis Offline
|
Posted: Wed Jun 13, 2007 10:35 pm Post subject: |
|
|
|
|
Just so you know, i'm almost ready to release the new team tracker, but w/ players . If you want to speed up the process(most likely not) you could post a reply here telling me about arrays so i don't have to google. That would be sweet. Otherwise that's cool. |
|
Back to top |
|
|
tcsoccerman Server Help Squatter
Age:32 Gender: Joined: Jan 15 2007 Posts: 694 Location: Atlantis Offline
|
Posted: Wed Jun 20, 2007 9:20 pm Post subject: |
|
|
|
|
As i am coding more, i don't seem to enjoy having so much code on one page. therefore, i've tried adding a new page something like this:
the new file would have this:
namespace Team_Tracker
{
public partial class MainForm : Form
{
public players()
{
InitializeComponent();
}
yadayadayada void money(blah, blah)
{
}
}
} |
and the one that has to much code/original would have this:
namespace Team_Tracker
{
public partial class MainForm : Form
{
[STAThread]
public static void Main(string[] args)
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new MainForm());
}
public MainForm()
{
InitializeComponent();
}
//lots of code
//too much code
}
} |
would that be correct? |
|
Back to top |
|
|
Cyan~Fire I'll count you!
Age:36 Gender: Joined: Jul 14 2003 Posts: 4608 Location: A Dream Offline
|
Posted: Thu Jun 21, 2007 12:17 am Post subject: |
|
|
|
|
I don't really understand what you're trying to do. Can you clarify? (And fix the horrible tabbing in the first code block, please.) |
|
Back to top |
|
|
tcsoccerman Server Help Squatter
Age:32 Gender: Joined: Jan 15 2007 Posts: 694 Location: Atlantis Offline
|
Posted: Wed Aug 22, 2007 7:45 pm Post subject: |
|
|
|
|
hey there i'm back with this project now.
i've learned alot since the last time i tried. i'm now working on something that cyanfire suggested back on making a class:
class Player
{
int blah;
string foo;
};
i've run into one problem. i need to find a way to instintate the class, naming it by the players name. it will look something likethis:
Player <playernamehere> = new Player();
the problem is, i don't know how to "insert" the players name.
In c there is a snprintf() function, (commonly including the string buf) that can help with these sort of problems, or others like it. google searches didn't relate snprintf with c# . can anyone help me think of a way of inserting the players name?
EDIT:also i can't acces the file due to protection levels :\. I think i'm gonna just take the old approach to it. |
|
Back to top |
|
|
Cyan~Fire I'll count you!
Age:36 Gender: Joined: Jul 14 2003 Posts: 4608 Location: A Dream Offline
|
|
Back to top |
|
|
tcsoccerman Server Help Squatter
Age:32 Gender: Joined: Jan 15 2007 Posts: 694 Location: Atlantis Offline
|
Posted: Tue Aug 28, 2007 7:14 pm Post subject: |
|
|
|
|
i did as you said and that really isn't what i wanted, but it was helpful in other ways. basically i'll give it straight out.
instead of having to do
player Bob = new player();
or
player hannah = new player();
or some other SET name, i want to do something like this:
player txtboxname.Text = new player();
excepty you can't do that, becasue "txtboxname.Text" gives an error. how can i do this correctly? |
|
Back to top |
|
|
tcsoccerman Server Help Squatter
Age:32 Gender: Joined: Jan 15 2007 Posts: 694 Location: Atlantis Offline
|
|
Back to top |
|
|
Cyan~Fire I'll count you!
Age:36 Gender: Joined: Jul 14 2003 Posts: 4608 Location: A Dream Offline
|
Posted: Wed Aug 29, 2007 1:15 pm Post subject: |
|
|
|
|
OK, I really have to ask this. Did you really do any kind of C# tutorial before you started this stuff? It seems to me like you are copy+pasting and modifying code without any kind of understanding of what it actually does... |
|
Back to top |
|
|
tcsoccerman Server Help Squatter
Age:32 Gender: Joined: Jan 15 2007 Posts: 694 Location: Atlantis Offline
|
Posted: Wed Aug 29, 2007 10:51 pm Post subject: |
|
|
|
|
you're half right half wrong.
i took no tutorial.
i learned c programming before c# though, so i have the basics(or do i) down. i do understand what i'm doing for the most part, it's just my c# dictionary is very small. here's how it works for me
code
find problem
google problem
google
google
google
ask this topic
solved
ty for answering though. and if you're wondering, i do realize that the above post is wrong, and missing some code. i got that code though. ty for you're help so far. |
|
Back to top |
|
|
Cyan~Fire I'll count you!
Age:36 Gender: Joined: Jul 14 2003 Posts: 4608 Location: A Dream Offline
|
Posted: Wed Aug 29, 2007 11:41 pm Post subject: |
|
|
|
|
Do a tutorial. Your questions have indicated a lack of basic understanding of the language and it would be good for you to sort of start over, sorry to say it. |
|
Back to top |
|
|
tcsoccerman Server Help Squatter
Age:32 Gender: Joined: Jan 15 2007 Posts: 694 Location: Atlantis Offline
|
Posted: Wed Aug 29, 2007 11:52 pm Post subject: |
|
|
|
|
ok i will do a tutorial, but one quick question. how can you access already existant created instances of classes without using the "new" operator? |
|
Back to top |
|
|
CypherJF I gargle nitroglycerin
Gender: Joined: Aug 14 2003 Posts: 2582 Location: USA Offline
|
Posted: Thu Aug 30, 2007 7:12 am Post subject: |
|
|
|
|
You create a instance of a object when you use the 'new' operator.
You'll need to keep the object reference around to use elsewhere. _________________ Performance is often the art of cheating carefully. - James Gosling |
|
Back to top |
|
|
tcsoccerman Server Help Squatter
Age:32 Gender: Joined: Jan 15 2007 Posts: 694 Location: Atlantis Offline
|
Posted: Thu Aug 30, 2007 10:52 am Post subject: |
|
|
|
|
ok thank you. |
|
Back to top |
|
|
|