Search the Community
Showing results for tags 'c-sharp'.
-
I have a program that needs to run automatically in multiple user interactive sessions (ie, the logged on desktop). How would I go about logging in multiple users programmatically? I was hoping to use the built in auto-logon feature to log the primary user on, which then starts a program that would also log on the required user accounts. I'm not too worried about security for the time being and it needs to work on Windows 7. Thanks!
-
Hey everyone, I've made some code to generate an array full of random numbers (between 2 points), to create a "Set" of data to be analyzed. This works fine - I've got my random set, but for it to be counted as a valid set, it has to have no duplicate numbers. Sure, I can make the RNG to a really high number and hope I don't get a duplicate, but that is beside the point. (In fact, I tried that and still got 3 repeated numbers...) How would I make my RNG generate a random set of numbers without duplicates? Here's the code for my RNG if this is of any help: int length = 9; Random r = new Random(); int yes; int[] setS = new int[9]; for (int i = 0; i < length; i++) { setS[i] = r.Next(1, 19); Console.WriteLine(setS[i]); } I've had a look at multiple sites, such as StackOverflow and I don't fully understand the methods people are showing on how to solve this problem. Thanks for any help given.
- 20 replies
-
Hey everyone. Here is a really simple one for you today - Like I probably know how to do it myself - its just been a long time since I've coded in C#. How do I get a file to save? I've got a template text file (a simple .txt) - imported it to the program - did some processing (i.e split the lines, added each new index to an appropriate list) - made some edits (read in the original line I wish to edit in the txt file - made a change - refreshed the lists and the change is there). However, I can not for the life of me figure out how to get it to save the text file. I have been taught it in university - but I just can't seem to get it to work. The dialog appears, but when I chose to save over a file, it gives me the confirmation, but no changes occur. I've tried saving as a new file - but even then the new file doesn't appear in the directory I've chosen. Heres my "Broken Save Code" private void saveToolStripMenuItem_Click(object sender, EventArgs e) { saveFileDialog1.InitialDirectory = currentDirectoryName; if (saveFileDialog1.ShowDialog() == DialogResult.OK) { fileName = saveFileDialog1.FileName; } } Again, Really stupid, probably really simple. But any help would be appreciated
-
So for some reason, when it run's normally, my program will print the first string it get's as a single char, but as soon as it's in debug mode and hits the breakpoint, it writes the entire string into the console. I am finding this to be annoying, can anyone help? The .cs file will be attached to this post. Program.cs
-
Hi there, So basically I am a 17 year old student from South Africa and I am looking to teach myself to code games with the Unity3D engine. I am looking to create a multiplayer FPS game, but I understand that I first will have to learn to code and learn the basics of Unity. I would like to know if anyone is willing to assist me (pointing me towards books, sites, tutorials etc) with my project. I would greatly appreciate any help/advice. Kind Regards Luan
- 7 replies
-
- unity
- game development
-
(and 3 more)
Tagged with:
-
Hi, i have a quick question which i couldnt find an answer for: My current WPF app has a lot of images which makes the .exe over 10mb bit (which is too big for me...) Most of those images wont be changed during updates so i would like to somehow exclude them from the .exe... I would still like to keep that stuff as a built-in resource and i dont want it to be an actual .png/.jpg/some_other_format file, i was thinking of an API approach, app downloads those images from an API but that would cause much more load on our servers since, again, i dont want to store those images in a easy to access file so no caching would be implemented ... probably Thanks ... i hope i was clear enough , if i wasnt, tell me ... please ... idk how to write this stuff ... (Im giving images as an example here, but it should work with any file that is set in Visual Studio to build with the app)
-
Hi Everyone, I haven't done any programming for a while (like upwards of a year to a year and a half or so), and decided to try and make a program to convert a collection of images to a PDF. The program should work - and I believe it will work, however - I seem to be having an issue when it comes to saving the file. With my code, I can get the program to run and execute fine, but when I go to save the document with a SaveFileDialog, the document doesn't save. I could be missing something extremely simple, but cannot seem to be able to figure it out. As such, I was hoping people on the forum might be able to help me out. My program's concept was based around this video, but modified by me so I can see the images loaded in a ListBox and preview the image when clicked in a PictureBox (That bit works fine), using code from the link below the video. It's just the document saving/output I seem to be having. Unlike the example, I do not want to hard code a save path or file name, but use a SaveFileDialog. Just as a note, to do the PDF Conversion, I am using the PdfSharp library (like the one used in the video in the spoiler). Here is my code: Thanks for your time and input. This issue is probably me being stupid...
-
-Probably Not Important- Im currently building a simple Launcher for my games , i have a Installer which downloads a .zip file and then decompresses it to the selected directory. That .zip file has a game's EXE file which also holds the game version (.exe version is game version), and my launcher has a saved install location and a way to locate that file and get its version. -Actual Question- My Question Is : -I need a way to track if there is a new Updated version of the game and idk how to do it, but i have some ways that might work. 1. On My GITHub Page, just store a .txt file with the newest version and if it doesnt match the .exe version , then show a Update dialogue. 2. I wanted to use some kind of a database or something, so that i could save both the version, new .zip download link and some other additional info if it is needed. I dont know if any of these ways of doing this are good, im looking if someone has a better or simpler way/idea of doing this, or is one of the above good at all ? P.S. Im using WPF and C# Thank you !
-
I know the basics of c++ from working with Arduinos, but I want to move in the direction of creating programs for a computer. I looked into finding tutorials on c++, but all I found was tutorials of Writing programs that interacted with a command prompt... I know that is good to start off with, but I want to learn how to create a Program that runs in its own window and create my own User Interface. 1) Are there any good tutorials on creating visual programs with c++? 2) Is c++ even a good language for creating visual programs? should I try another language? 3) (kinda unrelated) I have heard of C#, what is the main use for C#? Would it be a better option than C++?
-
I need some help as to why my program works when I have it go in debug mode, but fails when it runs normally. I'll provide a link to the git (https://github.com/TechNGamer/mod-copier/tree/not-completed), it's the ExternalUpdator project that doesn't seem to be working as expected. What I expect it to do is to be copied to the temp folder, run as admin, then proceed to download the "newest" version from GitHub. Yet, when I run it normally, it doesn't work. When I run it in debug mode, it works. No changes what so ever from any of the command line arguments. These are the arguments passed for the test run: --main-program=TechNGamer:mod-copier:Mod.Copier.Manual.Install --install-path="E:\Personal Files\Programs\Git Repositories\Mod Copier\Mod Copier\bin\Debug"
-
So I'm redoing my ID3#-Reader for the reason that I didn't like how it was made in the first part. However, when I go and run this test I find it odd that Test 2 (method: TagComptest1()) complete's slower than Test 3 (method: TagCompTest2()). Yet, Test 3 has a lot more data in it, so why is it faster at completing? The times are 00:00:00.0001633 for Test2 and 00:00:00.0000707 for Test3. Is Visual Studio doing something behind the scenes and if so, can someone explain how it might be optimizing my code? The appropriate scripts are below: UnitTest1.cs: public void TagCompTest1() { FileStream fileStream = File.Create( Path.Combine( Environment.GetFolderPath( Environment.SpecialFolder.Desktop ), "ID3 Test Folder", "Test2.log" ) ); DateTime now = DateTime.Now; Random random = new Random(); for ( int i = 0; i < 5; i++ ) { Tags.IsKnownTag( Tags.STRING_TAGS[ random.Next( Tags.STRING_TAGS.Length ) ] ); } WriteToLog( $"Took 5 rounds of calling IsKnownTag ~{( DateTime.Now - now)/5}.\n", fileStream ); now = DateTime.Now; Tags.IsKnownTag( "XXXX" ); WriteToLog( $"Took ~{DateTime.Now - now} to validate if 'XXXX' was a valid tag.", fileStream ); } [TestMethod] public void TagCompTest2() { FileStream fileStream = File.Create( Path.Combine( Environment.GetFolderPath( Environment.SpecialFolder.Desktop ), "ID3 Test Folder", "Test3.log" ) ); DateTime now = DateTime.Now; Random random = new Random(); for ( int i = 0; i < 5; i++ ) { string[] tags = { Tags.STRING_TAGS[ random.Next( Tags.STRING_TAGS.Length ) ], Tags.STRING_TAGS[ random.Next( Tags.STRING_TAGS.Length ) ], Tags.STRING_TAGS[ random.Next( Tags.STRING_TAGS.Length ) ], Tags.STRING_TAGS[ random.Next( Tags.STRING_TAGS.Length ) ], Tags.STRING_TAGS[ random.Next( Tags.STRING_TAGS.Length ) ] }; Tags.IsAnyKnownTag( tags, out string[] dummy ); } WriteToLog( $"Took 5 rounds of calling IsAnyKnownTag ~{( DateTime.Now - now ) / 5}.\n", fileStream ); } Tags.cs: public static bool IsKnownTag( string tag ) { int start = 0, end = 0; // This if tree helps cut the processing time down by only looking at the potion of the list or, if it's the only type, the string itself. #region IfTree if ( tag.StartsWith( "A" ) ) { end = 3; } else if ( tag.StartsWith( "C" ) ) { start = 3; end = 5; } else if ( tag.StartsWith( "E" ) ) { start = 5; end = 8; } else if ( tag.StartsWith( "G" ) ) { start = 8; end = 10; } else if ( tag.Equals(STRING_TAGS[10]) ) { return true; } else if ( tag.StartsWith( "M" ) ) { start = 11; end = 13; } else if ( tag.Equals( STRING_TAGS[ 13 ] ) ) { return true; } else if ( tag.StartsWith( "P" ) ) { start = 14; end = 19; } else if ( tag.StartsWith( "R" ) ) { start = 19; end = 21; } else if( tag.StartsWith( "S" ) ) { start = 21; end = 25; } else if ( tag.StartsWith( "T" ) ) { start = 25; end = 71; } else if ( tag.StartsWith( "U" ) ) { start = 71; end = 74; } else if ( tag.StartsWith( "W" ) ) { start = 74; end = 83; } #endregion IfTree // Itterates over the STRING_TAGS array and checks only the strings it needs to. for ( int i = start; i < end; i++ ) { if ( STRING_TAGS[ i ].Equals( tag ) ) { return true; } } return false; } public static bool IsAnyKnownTag( string[] tags, out string[] areKnownTags ) { // Creates a list of string to store all the right tags. List<string> areTags = new List<string>(); // Loops through all the tags checks them with the IsKnownTag method. foreach ( string tag in tags ) { // If method returns true, add the tag to the List<string>, otherwise, do nothing with it. if ( IsKnownTag( tag ) ) { areTags.Add( tag ); } } // Checks to see if the list is greater than 0, if true, makes the areKnownTags assigns it to the output of areTags.ToArray() and returns true. // Otherwise it set's areKnownTags to null and returns false. if ( areTags.Count > 0 ) { areKnownTags = areTags.ToArray(); return true; } else { areKnownTags = null; return false; } }
-
So I'm making my own ID3v2 Tag Reader, it seems to work very well atm. However, I don't seem to be able to get the APIC to work. Whenever it runs, it says the size of the APIC tag on my test file is 2,038,334 bytes, but when I extract the image, Windows File Explorer reports it's size at 511,281 bytes. The compressed flag is false, in fact, all the flags are false. What am I missing here? All the files can be found on my GitHub. The line where tags are found and processed are located here: https://github.com/TechNGamer/ID3-Sharp-Reader/blob/a6c1468b04caa3b6569d41cc0fd67048242b165b/ID3-Sharp-Reader/Tag_Loader.cs#L157 Can someone help and explain. I do also plan on cleaning up the code once the entire thing is working as intended.
-
I'm having trouble figuring out why I'm having issue's loading a damn .dll that a plugin for my program I made won't load in. The exception I keep getting always seems to change lines. Please help me, this isn't any homework shit or anything. It's a personal project. The project can be found on GitHub here.
-
- plugin
- dependencies
- (and 4 more)
-
UPDATE: 11/24/16 Happy thanksgiving and I have no idea how to delete this so I'll just leave this here: I HAVE ACCOMPLISHED EVERYTHING I NEEDED IN MY ORIGINAL POST SO DO NOT COMMENT PLEASE UPDATE: 8/10/16 I started school so I'm not gonna have as much time to work on this. ;-; UPDATE: 8/7/16 I fixed the Form1_Activated loop. UPDATE: 8/5/16 I will keep trying to fix the annoying loop that's caused whenever the form is activated. In the mean time I'll make a picture viewer similar to Windows Photo Viewer. I did this before but that was when I was using c# for the first time. Now I have a bit more knowledge and hopefully will improve it. UPDATE: 8/3/16 Here's what I have accomplished so far: 1. Downloading an image from a URL 2. Read and be able to select certain roots of the XML file - thanks to Nuluvius Here's what's left: 1. Close the XML file when a new or similar search is performed. There's no File.Close(); that I'm aware of. Also I'm using XDocument.Load(); to load the XML. 2. Being able to relocate the controls when the window is resized 3. Auto size the groupbox in case the the title is large and doesn't cut off(see the third picture) I will also provide the source code and .exe file's here: Updated: 8/7/16 Login: http://pastebin.com/94iLbkhF Image_Browser: http://pastebin.com/aDsbwb97 .exe: https://mega.nz/#!rAUEQK5C!xg9hjpKnGwMZrlQ4XjT6dkJ9VFhyPBllcAcutrdkJek To login: If you HAVE an Inkbunny account: type in your information and login, as soon as a SID is received, the password is destroyed. If you DON'T have one and do not wish to make one: use "guest" for the username and leave the password blank. Note that users have the option to block submissions from guests. I really hope links are allowed... I've included pictures of the app, just thought you might want to look at it, unless you don't want too. Here's the original post: *I'm just learning c# again as I haven't coded in a while, so don't make your answers too complicated please. Thanks.* I have 3 question for you guys: 1. How would I download a picture from a website? Ex. Image 2. How to read the values that I want from an xml output from a web server? 3. I want to access a variable thats in Form1(Login) from Form2(Image_Browser), how would I do this? Here's my code: http://pastebin.com/94iLbkhF Feel free to improve it, but don't steal it and claim it as your own. .-. I want to be able to get only the name of the submission, the account title, the thumbnail of the submission, the rating of the submission such as "Mature," and the full screen URL of the image from the XML output of the server, everything else is useless for me right now. I have tried nothing yet as I'm still a newbie with c#. Thanks! Here's a sample of the XML from a web server: <submission> <submission_id>...</submission_id> <hidden>...</hidden> <username> <![CDATA[ Kinaj ]]> </username> <user_id>...</user_id> <create_datetime>...</create_datetime> <create_datetime_usertime>...</create_datetime_usertime> <last_file_update_datetime>...</last_file_update_datetime> <last_file_update_datetime_usertime>...</last_file_update_datetime_usertime> <thumbnail_url_huge_noncustom>...</thumbnail_url_huge_noncustom> <thumbnail_url_large_noncustom>...</thumbnail_url_large_noncustom> <thumbnail_url_medium_noncustom> <![CDATA[ https://inkbunny.net/thumbnails/medium/1609/1609080_Kinaj_alex_marie_schlie__die_t_r_noncustom.jpg ]]> </thumbnail_url_medium_noncustom> <thumb_medium_noncustom_x>...</thumb_medium_noncustom_x> <thumb_medium_noncustom_y>...</thumb_medium_noncustom_y> <thumb_large_noncustom_x>...</thumb_large_noncustom_x> <thumb_large_noncustom_y>...</thumb_large_noncustom_y> <thumb_huge_noncustom_x>...</thumb_huge_noncustom_x> <thumb_huge_noncustom_y>...</thumb_huge_noncustom_y> <file_name>...</file_name> <title> <![CDATA[ Close the Door ]]> </title> <deleted>...</deleted> <public>...</public> <mimetype>...</mimetype> <pagecount>...</pagecount> <rating_id>...</rating_id> <rating_name> <![CDATA[ Mature ]]> </rating_name> <file_url_full> <![CDATA[ https://inkbunny.net/files/full/1609/1609080_Kinaj_alex_marie_schlie__die_t_r.png ]]> </file_url_full> <file_url_screen>...</file_url_screen> <file_url_preview>...</file_url_preview> <submission_type_id>...</submission_type_id> <type_name>...</type_name> <digitalsales>...</digitalsales> <printsales>...</printsales> <friends_only>...</friends_only> <guest_block>...</guest_block> <scraps>...</scraps> </submission>
-
Hi guys, I'm looking for someone to aid me while making a Sliding Puzzle game. I already made the initial code and I can't figure out how to these methods: - randomizing initial blocks (done) - moving the blocks - checker as well if the blocks should move accordingly I'm using Texture2D for the blocks here's the code snip: