|
Apologies for the shouting but this is important.
When answering a question please:
- Read the question carefully
- Understand that English isn't everyone's first language so be lenient of bad spelling and grammar
- If a question is poorly phrased then either ask for clarification, ignore it, or mark it down. Insults are not welcome
- If the question is inappropriate then click the 'vote to remove message' button
Insults, slap-downs and sarcasm aren't welcome. Let's work to help developers, not make them feel stupid..
cheers,
Chris Maunder
The Code Project Co-founder
Microsoft C++ MVP
|
|
|
|
|
For those new to message boards please try to follow a few simple rules when posting your question.- Choose the correct forum for your message. Posting a VB.NET question in the C++ forum will end in tears.
- Be specific! Don't ask "can someone send me the code to create an application that does 'X'. Pinpoint exactly what it is you need help with.
- Keep the subject line brief, but descriptive. eg "File Serialization problem"
- Keep the question as brief as possible. If you have to include code, include the smallest snippet of code you can.
- Be careful when including code that you haven't made a typo. Typing mistakes can become the focal point instead of the actual question you asked.
- Do not remove or empty a message if others have replied. Keep the thread intact and available for others to search and read. If your problem was answered then edit your message and add "[Solved]" to the subject line of the original post, and cast an approval vote to the one or several answers that really helped you.
- If you are posting source code with your question, place it inside <pre></pre> tags. We advise you also check the "Encode "<" (and other HTML) characters when pasting" checkbox before pasting anything inside the PRE block, and make sure "Use HTML in this post" check box is checked.
- Be courteous and DON'T SHOUT. Everyone here helps because they enjoy helping others, not because it's their job.
- Please do not post links to your question into an unrelated forum such as the lounge. It will be deleted. Likewise, do not post the same question in more than one forum.
- Do not be abusive, offensive, inappropriate or harass anyone on the boards. Doing so will get you kicked off and banned. Play nice.
- If you have a school or university assignment, assume that your teacher or lecturer is also reading these forums.
- No advertising or soliciting.
- We reserve the right to move your posts to a more appropriate forum or to delete anything deemed inappropriate or illegal.
cheers,
Chris Maunder
The Code Project Co-founder
Microsoft C++ MVP
|
|
|
|
|
void BtncopyClick(object sender, EventArgs e)
{
string filename=@"E:\\Files\\Reports\\R^ECG^_0_1688^Jones^^_20160711065157_20160711065303 - Copy (4) - Copy.pdf";
string sourcepath=@"E:\\Anusha";
string targetpath=@"E:\\Anusha\\aaa";
string sourcefile= System.IO.Path.Combine(sourcepath,filename);
string destfile= System.IO.Path.Combine(targetpath,filename);
if (!System.IO.Directory.Exists(targetpath))
{
System.IO.Directory.CreateDirectory(targetpath);
}
System.IO.File.Copy(sourcefile, destfile, true);
if (System.IO.Directory.Exists(sourcepath))
{
string[] files = System.IO.Directory.GetFiles(sourcepath);
foreach (string s in files)
{
filename = System.IO.Path.GetFileName(s);
destfile = System.IO.Path.Combine(targetpath, filename);
System.IO.File.Copy(s, destfile, true);
}
}
else
{
MessageBox.Show("File doesn't exist");
}
}
void BtnmoveClick(object sender, EventArgs e)
{
String path = "E:\\Files\\25-11-2017";
String path2 = "E:\\Anusha\\aaa\\25-11-2017";
if (!File.Exists(path))
{
{
using (FileStream fs = File.Create(path)) {}
}
System.IO.Directory.Move("E:\\Files\\25-11-2017",@"E://Anusha//aaa");
File.Move(path, path2);
MessageBox.Show("File Moved");
}
}
i HAVE WRITTEN BELOW code to copy and move the folder ,I am not getting any compiling errors but while i am trying to click on button on output form it was showing as termination.
|
|
|
|
|
Compiling does not mean your code is right!
Think of the development process as writing an email: compiling successfully means that you wrote the email in the right language - English, rather than German for example - not that the email contained the message you wanted to send.
So now you enter the second stage of development (in reality it's the fourth or fifth, but you'll come to the earlier stages later): Testing and Debugging.
Start by looking at what it does do, and how that differs from what you wanted. This is important, because it give you information as to why it's doing it. For example, if a program is intended to let the user enter a number and it doubles it and prints the answer, then if the input / output was like this:
Input Expected output Actual output
1 2 1
2 4 4
3 6 9
4 8 16 Then it's fairly obvious that the problem is with the bit which doubles it - it's not adding itself to itself, or multiplying it by 2, it's multiplying it by itself and returning the square of the input.
So with that, you can look at the code and it's obvious that it's somewhere here:
private int Double(int value)
{
return value * value;
}
Once you have an idea what might be going wrong, start using the debugger to find out why. Put a breakpoint on the first line of the method, and run your app. When it reaches the breakpoint, the debugger will stop, and hand control over to you. You can now run your code line-by-line (called "single stepping") and look at (or even change) variable contents as necessary (heck, you can even change the code and try again if you need to).
Think about what each line in the code should do before you execute it, and compare that to what it actually did when you use the "Step over" button to execute each line in turn. Did it do what you expect? If so, move on to the next line.
If not, why not? How does it differ?
Hopefully, that should help you locate which part of that code has a problem, and what the problem is.
This is a skill, and it's one which is well worth developing as it helps you in the real world as well as in development. And like all skills, it only improves by use!
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Hello everyone, I really need help about problem with loading of WaveFrontLoader.cs
I have tried to load obj but GameWindow doesn't show model why because it has nothing any errors.
I really want to have resolve WaveFront on my GameWindow
I will show code and file:
using OpenTK;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
namespace Tutorial_08.net.sourceskyboxer
{
public class WaveFrontLoader
{
private static List<Vector3> inPositions;
private static List<Vector2> inTexcoords;
private static List<Vector3> inNormals;
private static List<float> positions;
private static List<float> texcoords;
private static List<int> indices;
public static RawModel LoadObjModel(string filename, Loader loader)
{
inPositions = new List<Vector3>();
inTexcoords = new List<Vector2>();
inNormals = new List<Vector3>();
positions = new List<float>();
texcoords = new List<float>();
indices = new List<int>();
int nextIdx = 0;
using (var reader = new StreamReader("Contents/" + filename + ".obj", Encoding.UTF8))
{
string line = reader.ReadLine();
while (true)
{
string[] currentLine = line.Split(new[] { ' ' }, StringSplitOptions.None);
if (currentLine[0] == "v")
{
Vector3 pos = new Vector3(float.Parse(currentLine[1]), float.Parse(currentLine[2]), float.Parse(currentLine[3]));
inPositions.Add(pos);
if (currentLine[1] == "t")
{
Vector2 tex = new Vector2(float.Parse(currentLine[1]), float.Parse(currentLine[2]));
inTexcoords.Add(tex);
}
if (currentLine[1] == "n")
{
Vector3 nom = new Vector3(float.Parse(currentLine[1]), float.Parse(currentLine[2]), float.Parse(currentLine[3]));
inNormals.Add(nom);
}
}
if (currentLine[0] == "f")
{
Vector3 pos = inPositions[0];
positions.Add(pos.X);
positions.Add(pos.Y);
positions.Add(pos.Z);
Vector2 tc = inTexcoords[0];
texcoords.Add(tc.X);
texcoords.Add(tc.Y);
indices.Add(nextIdx);
++nextIdx;
}
reader.Close();
return loader.loadToVAO(positions.ToArray(), texcoords.ToArray(), indices.ToArray());
}
}
}
}
}
in Game.cs:
loader = new Loader();
shader = new StaticShader();
renderer = new Renderer(shader);
model = WaveFrontLoader.LoadObjModel("example", loader);
texturedModel = new TexturedModel(model, new ModelTexture(loader.loadTexture("example")));
entity = new Entity(texturedModel, new Vector3(0, 0, -40), 0, 0, 0, 1);
camera = new Camera();
Download myproblem.7z from mega.nz
How do I resolve if wavefront obj displays in GameWindow Thank you for checking and resolving.
Please promise me! I want listen how do I get working wavefrontloader.cs should parse to obj file. Thank you!
I am very broken since Sunday to today I can not resolve it cause WavefrontLoader can know Obj but doesn't show in GameWindow. How do I get successful loading obj. But it is really porting from LwjGL into C# OpenTK. Thanks for help!
|
|
|
|
|
hi
i have two forms
form1 run with button click and doing a foreach loop
i want to every time need to show form2 in the foreach loop, then pause button click event until i have to select an item from form2.listbox then continue button click event
please help me what should i do?
thanks you dear friends ![Rose | [Rose]](https://codeproject.global.ssl.fastly.net/script/Forums/Images/rose.gif)
|
|
|
|
|
Simply disable the control before you start your loop. Or disconnect the event when going into the loop, and reconnect when done. Or in the event, check whether you're looping and exit.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
Simple:
Form2 f2 = new Form2();
f2.ShowDialog(); the Form1 code will cease working until Form2 is closed, and then continue from the next line.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
i designed real estate management system in c#.net and sql server and then have faced problem coding in part of managimg chegues the idea is that the system must send warning message when the contract going to end for examlpe.
in a litle words: i want help how to write code produce warning message before specific time in in c#.net and sql server.
thanks i hope you help me,please i am my final project
|
|
|
|
|
We can't be specific; we have no idea how your system works, how it's written, or even where you get "contract" information from.
But there are three basic ways:
1) A separate application which is run by the system at scheduled intervals which checks the times and reports.
2) A Timer in your application which does the same thing - runs and the contracts are checked each time the Tick handler is called.
3) A Thread in your application which does the same thing: sleeps for a period, then checks the contract times.
Which is best for your application? No idea!
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
ahmedoze wrote: i hope you help me,please i am my final project I never did one of those.
So, assuming you have a list of stuff with dates in SQL Server. When the program runs, you fetch all the mail-adresses that have the date "today". Check with an "if" whether or not to send a mail. What part of that are you stuck on?
For bonus points; if you run the program again, or if it crashes half-way, it may send some mails twice. To be correct, you'd need to remember whom you sent a mail and exclude them when fetching todays stuff.
How much time until your deadline?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
Eddy Vluggen wrote: How much time until your deadline? He won't know until he can get his application to post a warning message. 
|
|
|
|
|
If this is your final project, you should know by now how to create a specification. You only have the highest level of requirement there. When you say that you want the system to send a warning message, for instance, how do you want that warning to be delivered? Are you sending it to a user logged into your system? Are you sending it to clients via email/text? You need to spend more time working out what your requirements are.
If, for instance, you wanted just to send this to a client via email, then you know that there is a possibility that the client isn't going to be logged into your system at an appropriate point. This tells you that you want to write something that can send updates to people as an unattended operation - in other words, you're probably going to want to write a service. You also need some way to identify that you have already sent a notification, so you probably want to have some attribute in the database, against the client, to identify that the message has been sent.
We aren't going to write your code for you, but we will give you ideas on how to start coming up with your own solution.
This space for rent
|
|
|
|
|
I wrote a command line program to create a process and run a simulation in the background. This worked fine for many years but IT pushed something to our computers and it no longer works efficiently. I use this program to start 200+ simulation runs and as they queued up, they would use 100% loading all my workstation 40 cores until they finished in about 15 seconds. I am not sure what IT pushed to our computers but now I can only get about a 30% usage of my cores and takes 45 seconds to complete. The program only gets about 12 or so simulations running simultaneously. So I tried using Start-Process in powershell and low and behold, it would queue up enough simulations to run to load all 40 cores to 100%. Can anyone tell my how I can get the Process.start to use all of the processing power. IT does not know what has changed to cause the issue. It is a policy setting as IT did test a clean computer without the required policy settings and the Process.Start was able to load all of the cores.
Here is the code I used to start running a single process in C#.
try
{
Process process = new Process();
if (optionHidden)
{
process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
}
process.StartInfo.FileName = application;
process.StartInfo.Arguments = arguments;
process.Start();
if (optionWait)
{
process.WaitForExit();
}
}
catch (Exception e)
{
Console.WriteLine("Failed to launch {0} because of {1}", application, e.Message);
}
The application name is nStart and looks like this to start all of the simulation runs.
nStart /hidden nDOF.exe MM0000.ndof
nStart /hidden nDOF.exe MM0001.ndof
nStart /hidden nDOF.exe MM0002.ndof
nStart /hidden nDOF.exe MM0003.ndof
.
.
.
The powershell script looks like this.
Start-Process .\nDOF.exe -ArgumentList 'MM0000.ndof'
Start-Process .\nDOF.exe -ArgumentList 'MM0001.ndof'
Start-Process .\nDOF.exe -ArgumentList 'MM0002.ndof'
Start-Process .\nDOF.exe -ArgumentList 'MM0003.ndof'
.
.
.
|
|
|
|
|
This has nothing to do with your code.
This is a policy problem. Your IT department is going to have to go back through what they change in policies and installs to figure out what's causing this. You should just have to supply them with the date that you noticed the problem occurring and they should be able to look up what's been changed in their change control system. If they don't have such a system, that's a huge problem and you just uncovered a major hole in their processes.
|
|
|
|
|
Yes it is but I have to find the issue and they may still not allow it to be changed. IT has found one policy that allowed the loading to increase to 70% which was "allow process elevation". This was turned on to prevent bad actors from taking control of the computer. I believed the powershell and C# use the same .NET process and was just trying to figure out why they are handled differently and if I could modify my code to work the same. Thanks for the input.
|
|
|
|
|
This cmdlet is implemented by using the Start method of the System.Diagnostics.Process class.
So, the code that PowerShell uses is similar.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
Hi, I am new in Programming. I am writing a simple app using C# in which i want send data to server, data includes URL with two parameters. When i try to send data to server it just sends the URL but not parameters. Can you help me regarding this.
And i have one more problem that i want to stop send data to server when stop button pressed. What method i can use for it.
Thanks.
What I have tried:
var postData = ("id1="+"123456");
postData += ("&id2="+"0123456789");
var request = (HttpWebRequest)WebRequest.Create("http://abc.xyz.com");
// var postData = "keyid1=id1";
// postData += "&keyid2=id2";
var data = Encoding.ASCII.GetBytes(postData);
Console.WriteLine(data);
request.Method = "POST";
request.ContentType = "multipart/form-data";
Console.WriteLine(request.ContentType);
request.ContentLength = data.Length;
using (var stream = request.GetRequestStream())
{
stream.Write(data, 0, data.Length);
stream.Close();
}
var response = (HttpWebResponse)request.GetResponse();
if (response.StatusCode != HttpStatusCode.OK)
{
Console.WriteLine("Status Code not OK");
}
var responseString = new StreamReader(response.GetResponseStream()).ReadToEnd();
if (string.IsNullOrWhiteSpace(responseString))
{
Console.WriteLine("Response string is invalid");
}
else
{
Console.WriteLine("Response: " + responseString);
}
response.Close();
-- modified 20hrs ago.
|
|
|
|
|
What is the actual text of the POST request that gets sent, and what is the response received from the server?
|
|
|
|
|
Hi Richard,
Thank you very much. Actually the problem was related to Server, It may not be set up to accept a POST at that URL. presently it works fine with Get method. Could you help me how i can stop this request to send to server when stop button pressed.
|
|
|
|
|
A better idea is to have a Send button. That way the send operation does not get executed until the user calls it.
|
|
|
|
|
yeah, i have Activate button. When i press activate button then it sends data to the server but now i have one more STOP button, I want that when i would press STOP button then it should stop to send request to Server. Thank you in advance.
|
|
|
|
|
When you press the Activate button the request will be sent to the server in microseconds at most, so there is no way you could react fast enough to stop it. I don't understand what you think you can achieve with this button.
|
|
|
|
|
Okay, pretty simple question, but I'm struggling in figuring it out. I need a label (that's reading from a text file) to return only certain values from within that same text file. The code I have is below:
private void btnCalculate_Click(object sender, EventArgs e)
{
string name = txtName.Text;
string number = txtNumber.Text;
double hourlyRate = Convert.ToDouble(txtPay.Text);
double hoursWorked = Convert.ToDouble(txtHours.Text);
double grossPay = 0.0;
TextWriter txt = new StreamWriter("employee_information.txt");
if (hoursWorked <= 40)
grossPay = hourlyRate * hoursWorked;
else
grossPay = (hourlyRate * 40) + (hourlyRate * 1.5) * (hoursWorked - 40);
txt.Write("Employee Name: "+ txtName.Text + " " + txtNumber.Text + " " + txtPay.Text + " " + txtHours.Text);
txt.Close();
try
{
using (StreamReader sr = new StreamReader("employee_information.txt" ))
{
string line = sr.ReadToEnd();
lblInformation.Text = line;
}
}
catch (Exception ex)
{
lblInformation.Text = "The file could not be read:";
}
}
I require the lblInformation.Text to read the Name value from the text file, along with the total pay being formatted (in a dollar amount) but it is currently reading all the information from said text file.
Any help or feedback is appreciated,
Thank you
|
|
|
|
|
We can;t help you with that - you need to look at your file and work out exactly how it stores the info you need. The chances are that it's stored by line (judging from your code) but what part of the line is the name and what the salary depend on the data content of each line - if you are lucky, it will be separated, delimited, or structured in order to make it relatively simple. But without the data? We can't even begin to guess.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|