Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
J

Johan Martensson

@Johan Martensson
About
Posts
70
Topics
26
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Get IP from IPInterfaceProperties
    J Johan Martensson

    Thanks for your reply I'm not sure how to tell which nic has the ip-number that I get from using your code. Anyway, I changed my code to this, looping the addresses and checking for IsDnsEligible, that seems to do the trick or am I missing something?

    foreach (UnicastIPAddressInformation address in ipProperties.UnicastAddresses)
    {
    if(address.IsDnsEligible)
    {
    adapter.Address = address.Address.ToString();
    adapter.SubnetMask = address.IPv4Mask.ToString();
    break;
    }
    }

    http://johanmartensson.se - Home of MPEG4Watcher http://www.tinywebradio.com - Home of TinyWebRadio

    C# question com

  • Get IP from IPInterfaceProperties
    J Johan Martensson

    Hi, I'm trying to get the IP, subnet and gateway for my interfaces using IPInterfaceProperties but both UnicastAddresses and GatewayAddresses returns a collection... How do I know which one to use? Here is my loop and for now I'm just using UnicastAddresses[0] and GatewayAddresses[0] but that isn't always right

    internal static NetworkAdapter[] AddExtraInformation(ArrayList adapters)
    {
    NetworkInterface[] networkInterfaces = NetworkInterface.GetAllNetworkInterfaces();
    foreach (NetworkAdapter adapter in adapters)
    {
    foreach (NetworkInterface networkInterface in networkInterfaces)
    {
    if (!DescriptionToName(networkInterface.Description).Equals(adapter.DeviceName))
    continue;

    		adapter.Name = networkInterface.Name;
    		adapter.OperationalStatus = networkInterface.OperationalStatus.ToString();
    			
    		IPInterfaceProperties ipProperties = networkInterface.GetIPProperties();
    
    		if (ipProperties.UnicastAddresses != null)
    			if (ipProperties.UnicastAddresses.Count > 0)
    			{
    				adapter.Address = ipProperties.UnicastAddresses\[0\].Address.ToString();
    				adapter.SubnetMask = ipProperties.UnicastAddresses\[0\].IPv4Mask.ToString();
    			}
    			
    		if (ipProperties.GatewayAddresses != null)
    			if (ipProperties.GatewayAddresses.Count > 0) 
    				adapter.Gateway = ipProperties.GatewayAddresses\[0\].Address.ToString();
    		
    		break;
    	}
    }
    
    return (NetworkAdapter\[\])adapters.ToArray(typeof(NetworkAdapter));
    

    }

    http://johanmartensson.se - Home of MPEG4Watcher http://www.tinywebradio.com - Home of TinyWebRadio

    C# question com

  • Effective filestream
    J Johan Martensson

    Thanks a lot for you answer, it's a much better looking code and it's easier to read. I just love getting feedback and watching how others write their code, there's a lot you can learn from that. So thank you again... :)

    http://johanmartensson.se - Home of MPEG4Watcher http://www.tinywebradio.com - Home of TinyWebRadio

    C# com beta-testing performance question code-review

  • execute .exe file
    J Johan Martensson

    If you need to pass some arguments to the exe file, here is an example

    Process p = new Process();
    ProcessStartInfo ps = new ProcessStartInfo();
    p.StartInfo = ps;

    ps.FileName = "file.exe";
    ps.Arguments = "Some commandline arguments";

    p.Start();

    http://johanmartensson.se - Home of MPEG4Watcher http://www.tinywebradio.com - Home of TinyWebRadio

    C# csharp question

  • Effective filestream
    J Johan Martensson

    Hi, I was wondering if someone could give me some feedback on this method. My goal is to join several files into one and it works but is this an effective way of doing it? Is there something I can do to speed it up and make it more effective? I have tried playing with the buffer-size and increasing it makes it faster up to a certain point.

    private void JoinFiles(string[] files, string outputFileName)
    {
    int buffSize = 1024;
    byte[] buffer = new byte[buffSize];

    FileStream fsSave = new FileStream(outputFileName, FileMode.CreateNew);
    
    foreach (string file in files)
    {
    	FileStream fs = new FileStream(file, FileMode.Open);
    	long fileSize = fs.Length;
    		
    	while (fs.Position < fileSize)
    	{
    		if (fileSize - fs.Position > buffSize)
    		{
    			if (buffer.Length < buffSize)
    				buffer = new byte\[buffSize\];
    
    			fs.Read(buffer, 0, buffSize);
    		}
    		else
    		{
    			buffer = new byte\[fileSize - fs.Position\];
    			fs.Read(buffer, 0, (int) (fileSize - fs.Position));
    		}
    
    		fsSave.Write(buffer, 0, buffer.Length);
    	}
    	fs.Close();
    }
    fsSave.Close();
    

    }

    http://johanmartensson.se - Home of MPEG4Watcher http://www.tinywebradio.com - Home of TinyWebRadio

    C# com beta-testing performance question code-review

  • Talking to htpasswd.exe
    J Johan Martensson

    The WriteLine adds a carriage return so that part is ok. I found what I had missed, the command-prompt needed to exit before it returned the result. So adding this before reading the output solved it:

    proc.StandardInput.WriteLine("exit");

    http://johanmartensson.se - Home of MPEG4Watcher

    C# testing beta-testing help question

  • Talking to htpasswd.exe
    J Johan Martensson

    True it generates a sort of md5 hashed passwords, but htpasswd.exe is a part of Apache webserver and they use a modified version of md5.

    http://johanmartensson.se - Home of MPEG4Watcher

    C# testing beta-testing help question

  • Talking to htpasswd.exe
    J Johan Martensson

    Can anyone see what I'm doing wrong here? All I want to do is generate a password with htpasswd.exe and it looked easy enough but it just gets stuck at ReadLine() :confused:

    ProcessStartInfo ps = new ProcessStartInfo();
    ps.FileName = Path.Combine(Application.StartupPath, "htpasswd.exe");
    ps.Arguments = "-n test";
    ps.CreateNoWindow = true;
    ps.UseShellExecute = false;
    ps.RedirectStandardInput = true;
    ps.RedirectStandardOutput = true;
    ps.RedirectStandardError = true;

    Process proc = new Process();
    proc.StartInfo = ps;
    proc.Start();

    proc.StandardInput.WriteLine("testing");
    proc.StandardInput.WriteLine("testing");

    string line = proc.StandardOutput.ReadLine();

    proc.Close();

    http://johanmartensson.se - Home of MPEG4Watcher

    C# testing beta-testing help question

  • Persistence in WF
    J Johan Martensson

    I have a question about the SqlWorkflowPersistenceService... I have set up a simple workflow to submit an article and someone will accept/reject it. In my client I have a form to submit the text and it gets stored in a DB. My problem is that I don't understand the blocked-column in the DB. The first time I run the client and submits an article, the workflow gets persisted and blocked is 0, the second time I run it and submits a second article, the first one gets blocked but the second is not. How can I unblock the workflow when they are submitted and keep them that way, they wont load in my manager client if they are blocked.

    public partial class FormSubmit : Form
    {
    	WorkflowRuntime workflowRuntime;
    	WorkflowLibrary.Services services = new WorkflowLibrary.Services();
    	
    	public FormSubmit()
    	{
    		InitializeComponent();
    
    		// Main component!
    		workflowRuntime = new WorkflowRuntime();
    
    		// ExternalDataExchangeService is needed to register local services
    		ExternalDataExchangeService exchangeService = new ExternalDataExchangeService();
    		workflowRuntime.AddService(exchangeService);
    		exchangeService.AddService(services);
    
    		// SqlWorkflowPersistenceService is needed for persistence
    		string connString = string.Format("Initial Catalog={0}; Data Source={1}; Integrated Security={2};", "WorkflowPersistenceStore", @"localhost\\SQLEXPRESS", "SSPI");
    		workflowRuntime.AddService(new SqlWorkflowPersistenceService(connString, true, new TimeSpan(0, 2, 0), new TimeSpan(0, 0, 20)));
    	}
    
    	private void btnSubmit\_Click(object sender, EventArgs e)
    	{						
    		Dictionary<string, object> wfArgs = new Dictionary<string, object>();
    		wfArgs.Add("ArticleId", 0);
    		wfArgs.Add("ArticleText", txtArticleText.Text);
    		WorkflowInstance workflowInstance = workflowRuntime.CreateWorkflow(
    							  typeof(WorkflowLibrary.ArticleWorkflow), wfArgs);
    
    		workflowInstance.Start();
    		workflowInstance.Unload();			
    	}
    
    	private void btnManager\_Click(object sender, EventArgs e)
    	{
    		new FormApproval().Show();
    	}
    }
    

    http://johanmartensson.se - Home of MPEG4Watcher

    WCF and WF question database security help workspace

  • TcpClient with proxy
    J Johan Martensson

    I want to use TcpClient and connect with a proxy like HttpWebRequest. Can I add a proxy to the TcpClient-object?

    http://johanmartensson.se - Home of MPEG4Watcher

    C# question

  • Convert PDF to text or html
    J Johan Martensson

    I tried iTextsharp but it really did a terrible job with my PDF so now I'm playing around with PDFBox and it seems to be doing a much better job.

    http://johanmartensson.se - Home of MPEG4Watcher

    C# csharp html career

  • Convert PDF to text or html
    J Johan Martensson

    Hi, I need to parse some text that's currently is in PDF-format so I'm thinking that converting it to text or html would be a good place to start. There are a lot of PDF-component out there for C#, has anyone of you tried anyone and can tell me which once are doing a good job. Thanks.

    http://johanmartensson.se - Home of MPEG4Watcher

    C# csharp html career

  • Recording from mic to mp3
    J Johan Martensson

    You're right, that could absolutely work, I will try it out Thanks for the help everybody

    http://johanmartensson.se - Home of MPEG4Watcher

    C# tutorial

  • Recording from mic to mp3
    J Johan Martensson

    Yes, I realize it has to created in memory or something like that, so what I'm looking for is a free audio library that takes the data from the mic and sends it directly to lame. My problem is that it must be free for commercial use.

    http://johanmartensson.se - Home of MPEG4Watcher

    C# tutorial

  • Recording from mic to mp3
    J Johan Martensson

    That article does pretty much what I have so far, it takes a wav-file and uses lame to create an mp3. I want to record directly to mp3.

    http://johanmartensson.se - Home of MPEG4Watcher

    C# tutorial

  • Recording from mic to mp3
    J Johan Martensson

    Thanks for your answer but I was hoping that there might be a simple library I could use

    http://johanmartensson.se - Home of MPEG4Watcher

    C# tutorial

  • Recording from mic to mp3
    J Johan Martensson

    Hi, Does anyone have an example to get me started on recording to an mp3 file. I want to record from the microphone and save it directly to an mp3. I have a working project but now I save it to wav and then send it to lame and I want to skip that step. Thanks, /Johan

    http://johanmartensson.se - Home of MPEG4Watcher

    C# tutorial

  • Looking for a SEO-tool
    J Johan Martensson

    I'm looking for a good analyze-tool for websites. I have used the tools at sitening.com but they are starting to charge for it as of June 1st. The kind of tool I'm looking for is something that analyzes a site and gives suggestions on how to improve the coding. It doesn't have to be a free service but that's always nice :)

    http://johanmartensson.se - Home of MPEG4Watcher

    ASP.NET com tools tutorial code-review

  • Scrolling text on a webform
    J Johan Martensson

    That one worked real nice, thanks I found another one over at dynamicdrive http://www.dynamicdrive.com/dynamicindex2/cmarquee.htm I sure can make something of these

    http://johanmartensson.se - Home of MPEG4Watcher

    ASP.NET html tutorial

  • Scrolling text on a webform
    J Johan Martensson

    Thanks, that one looked great in IE, but it doesn't seem to work in firefox. I will keep looking at more javascript examples.

    http://johanmartensson.se - Home of MPEG4Watcher

    ASP.NET html tutorial
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups