|
I'm working on a Service in C# that will be run on Windows and on Linux. On Linux you store app config in /etc, but on Windows XP it's "C:\Document and Settings\{USERNAME}\Local Settings\Application Data". How would I go about getting those file paths without having to worry about platform detection?
|
|
|
|
|
The app.config file is usually in the same folder as the .EXE. Assembly.GetExecutingAssembly.Location() will return the full path to the .EXE that is running. You can use the Path class to get just the path without the .EXE filename and use that to build the complete path to the app.config.
|
|
|
|
|
I use Iris Skin for change my program's form's skin but every time that I execute my program show me a messageBox and says you should register
how can I delete this messageBox ?
|
|
|
|
|
Do what it says and register the skining library. You'll have to pay for it, of course.
|
|
|
|
|
|
Hi
I use flowlayoutpanel in my form and i put a button in my flowlayoutpanel and i want to change button location in code but the location of my button doesn't change !
What should i do?
This is my code :
button1.location=new point(300,400);
|
|
|
|
|
From the doc: "The FlowLayoutPanel control arranges its contents in a horizontal or vertical flow direction...", so you have limited say about it. Depending on what it is you want, you might get it by adding a Panel of some Size, then add the Button to that Panel. That will allow you to choose where on the Panel the Button is, however the FLP will decide for you where the Panel goes.
Luc Pattyn [Forum Guidelines] [My Articles]
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
|
|
|
|
|
You cannot precisely position your controls in a FlowLayoutPanel. That is why it is called "flow" layout. If you want to position your controls precisely, then place your controls directly on the container.
|
|
|
|
|
hi in a project i saw a code that let a user to choose the camera
i dont want to let them do this how can i here is the code:
foundID = System.Reflection.Missing.Value;
wiaCamera = (ItemClass) wiaManager.Create( ref foundID );
thanks
|
|
|
|
|
Have a look at what wiaManager.Create does. Probably by passing no value it will ask the user to specifiy something, but if you pass avalue it won't
Bob
Ashfield Consultants Ltd
Proud to be a 2009 Code Project MVP
|
|
|
|
|
How Can I change skin's form in C# win Application ?
please give me project
modified on Sunday, November 22, 2009 11:44 AM
|
|
|
|
|
SajjadZare wrote: How Can I change skin's form in C# win Application ?
What exactly do you want to change, background, foreground, etc?
SajjadZare wrote: please give me project
If you need a complete solution then search the articles section.
|
|
|
|
|
Hi,
kindly let me know that, how may I split following text into strArray1?
string[] strArray1;
"0000061050","APPLE","500","17.69","20091122","14:15:17"
Thank you in Advance
(Riaz)
|
|
|
|
|
M Riaz Bashir wrote:
string[] strArray1;
"0000061050","APPLE","500","17.69","20091122","14:15:17"
This already looks like an array, are you sure you are asking the right question?
|
|
|
|
|
but when I try to split it, it gives me following answer with slashes
"\"0000061050\"\"APPLE\""
|
|
|
|
|
M Riaz Bashir wrote: but when I try to split it, it gives me following answer with slashes
"\"0000061050\"\"APPLE\""
I am afraid this is not a very good explanation. Can you post the actual code that you use, showing the results that you are getting.
|
|
|
|
|
Those slashes aren't really there.
|
|
|
|
|
Trust us, if you have:
string inString = "1234,5223,Apple,Bank";
string[] bits = s.Split(',');
foreach(string s in bits)
{
Console.WriteLine(s);
} You will see it works!
The extra slashes you can see in the debugger are confusing, but they are only there to "escape" the double quote characters - just as you would type them into a string. You will get used to it eventually, everyone does!
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
"Rumour has it that if you play Microsoft CDs backwards you will hear Satanic messages.Worse still, is that if you play them forwards they will install Windows"
|
|
|
|
|
It seems the series of double quotes itself is part of the string and the debugger escapes them with a \ (slash) to show them apart.
|
|
|
|
|
Dear All,
I have a datagridview which has three combobox column binded with DataSource and the datagridview is also binded with datasource.
As i have set the displaymember of comboxBoxColumn to "ColName" and ValueMember to "ColID" binding is ok.
when Im selecting something from those ComboBoxColumn while leaving that the value member appears at comboBox not the display member, Why the value member appears?
I have no other events for datagridview
Your cooperation is really appreciated
Abdul Rahaman Hamidy
Database Developer
Kabul, Afghanistan
|
|
|
|
|
Anybody knows how to set up checkbox column in a dataGridView, after setting the dataGridView1.DataSource?
At first the datagridview does not have any column, so after setting the dataSource it will create column automatically, but I don't know how to automatically set the column to be checkbox type.
Thanks.
|
|
|
|
|
Message Closed
modified 23-Nov-14 6:59am.
|
|
|
|
|
There's no need to add a new one. after setting the data source, the column is already there. I just need to change its type to be checkbox, but couldn't find a way to do that.
|
|
|
|
|
Why not simply define the bound columns at design time instead of autogenerating them?
|
|
|
|
|
I'm having trouble getting a schedule generator working properly. The way I have my program structured, there are 32 teams, all of which are a part of the "league". For the schedule generator, each team gets paired with another team for a game for 16 times (16 weeks). The specific problem is each team's schedule doesn't consist of more than 5 games maximum. (Each team should have 16 games.) In fact, it unusually varies from 1 game to 5 games. for each team's schedule.
I can't figure out what is wrong. Perhaps someone can point out my problem for me.
This is in my Team class:
[code]
private List<Game> games = new List<Game>();
public ReadOnlyCollection<Game> Games { get { return games.AsReadOnly(); } }
public void AssignGame(Game game)
{
games.Add(game);
}
public IEnumerable<Game> GamesWon { get { return games.Where(f => f.Played && f.Winner == this); } }
public IEnumerable<Game> GamesLost { get { return games.Where(f => f.Played && f.Winner != this); } }
[/code]
This is in my league class:
[code]
private const int HOME = 0;
private const int AWAY = 1;
private List<Team> teamList;
public ReadOnlyCollection<Team> Tms { get { return teamList.AsReadOnly(); } }
public int GetRanking(Team team)
{
TeamRankingComparer trc = new TeamRankingComparer();
List<Team> copyOfTeams = teamList.ToList();
copyOfTeams.Sort(trc);
return copyOfTeams.IndexOf(team) + 1;
}
private List<Game> games = new List<Game>();
public ReadOnlyCollection<Game> Games { get { return games.AsReadOnly(); } }
public void Schedule()
{
games.Clear();
Random r = RandomFactory.Create();
int weeks = 16;
for (int i = 0; i <= weeks; i++)
{
foreach (Team team in Teams)
{
List<Team> opponents = new List<Team>();
opponents.AddRange(Teams.Where(t => t != team));
Team opponent = opponents[r.Next(0, opponents.Count)];
if (!games.Any(g => g.Home == team && g.Away == opponent) && !games.Any(g => g.Home == team || g.Away == team))
{
games.Add(new Game(team, opponent));
}
else if (!games.Any(g => g.Home == team || g.Away == team))
{
games.Add(new Game(opponent, team));
}
}
}
}
[/code]
Other classes:
[code]
static class RandomFactory
{
private static Random globalRandom = new Random();
public static Random Create()
{
lock (globalRandom)
{
Random newRandom = new Random(globalRandom.Next());
return newRandom;
}
}
}
public class Game
{
public Game(Team home, Team away)
{
Home = home;
Away = away;
Home.AssignGame(this);
Away.AssignGame(this);
}
public Team Home { get; private set; }
public Team Away { get; private set; }
public Team Winner { get; private set; }
public bool Played { get { return Winner != null; } }
public void OnPlayed(Team winner)
{
Winner = winner;
}
}
internal class TeamRankingComparer : IComparer<Team>
{
public int Compare(Team team1, Team team2)
{
int team1Wins = team1.GamesWon.Count();
int team2Wins = team2.GamesWon.Count();
if (team1Wins > team2Wins)
{
return 1;
}
else if (team2Wins > team1Wins)
{
return -1;
}
else if (team1Wins == 0 && team2Wins == 0)
{
return String.Compare(team1.Name, team2.Name, true);
}
else
{
return 0;
}
}
}
public static class PrintScheduleStatistics
{
public static void PrintTeamStatistics(Team team)
{
foreach (Game g in team.Games)
{
string venue = "Home";
Team opponent = g.Away;
if (g.Home != team)
{
venue = "Away";
opponent = g.Home;
}
Console.WriteLine(String.Format("{0} to {1}", venue, opponent.Name));
}
}
}
[/code]
This call is in my Main() method:
[code]
League league = new League();
LoadRosters(league);
league.Schedule();
PrintScheduleStatistics.PrintTeamStatistics(league.Teams[1]);
[/code]
|
|
|
|