22
Mar/10
5

Convert BMP to JPG Command Line Utility (Free)

A small and free command line utility that converts a single .bmp file or a directory containing multiple .bmp files into jpg’s.

Requires .Net Framework 2.0 or later.

UPDATE! Sorry, the previous download File was corrupted. Please download this zip file now.

Download

  BMP2JPG.exe (8.0 KiB, 25,413 hits)

Help:
BMP2JPG :: Converts BMP to JPG (100% JPEG Quality only) :: Version 1.0

Converts BMP Files

Syntax :: BMP2JPG [Source Directory or File] [Destination Directory or File] [overwrite]

::
:: Examples
::
BMP2JPG "C:\Temp\My Bitmap.bmp" "C:\Temp\My JPEG File.jpg"
Converts a single File

BMP2JPG "C:\Temp\My BMP Folder" "C:\Temp\My JPEG Folder"
Converts all Files found in "C:\Temp\My BMP Folder" to "C:\Temp\My JPEG Folder"

BMP2JPG "C:\Temp\My BMP Folder" "C:\Temp\My JPEG Folder" overwrite
Converts all Files found in "C:\Temp\My BMP Folder" to "C:\Temp\My JPEG Folder"
Overwrites Existing Files

Author :: Tom Schindler, 2010 | http://www.microtom.net
Codename :: WIN32_ConvertBMP2JPG

Print This Post
(5 votes, average: 4.20 out of 5)
Loading ... Loading ...
907 views
27
Jul/09
0

Get XML Childnode Count

A Class to get the amount of child nodes using C#

?View Code CSHARP
1
2
3
4
5
6
7
public static int GetItemCount(string XmlFile)
{
    XmlDocument doc = new XmlDocument();
    doc.Load(XmlFile);
    XmlNodeList nodelist = doc.SelectNodes("books/book"); //replace with your XML path
    return nodelist.Count;
}
Print This Post
(3 votes, average: 4.67 out of 5)
Loading ... Loading ...
415 views
27
Jul/09
0

Remove Blank Lines from a Text File

I ran into a tricky Problem the other day. I had to remove the terminating blank lines in a CSV File as it was parsed by another program which did not handle the case of blank lines and thus failed. I figured this is not easy to do with a simple batch file so I created a little C# Program that does the trick.

The Program can be run from a command line and requires the path to the Text File where you want to remove the ending blank lines from.

Download Compiled Version: RemoveBlankLines

C# Code:

?View Code CSHARP
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
 
namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string file = args[0];
            if (file == "")
            {
                Console.WriteLine("Please enter the path to the File!");
                Environment.Exit(1);
            }
            if (!File.Exists(file))
            {
                Console.WriteLine("Could not find File {0}!", file);
                Environment.Exit(1);
            }
 
            RemoveBlankRowsFromCSVFile(file, 0);
            RemoveBlankRowsFromCSVFile(file, CountLines(file));
        }
 
        public static void RemoveBlankRowsFromCSVFile(string filepath, int lastline)
        {
            if (filepath == null || filepath.Length == 0)
            {
                throw new ArgumentNullException("filepath");
            }
 
            if (!File.Exists(filepath))
            {
                throw new FileNotFoundException("Could not find file.", filepath);
            }
 
            String tempFile = Path.GetTempFileName();
            int linecount = 0;
 
            using (StreamReader reader = new StreamReader(filepath))
            using (StreamWriter writer = new StreamWriter(tempFile))
            {
                String line = null;
                while ((line = reader.ReadLine()) != null)
                {
                    linecount++;
 
                    line = line.Replace("\r\n", "").Replace("\n", "").Replace("\r", "");
                    if (!line.Equals(String.Empty))
                    {
                        if ((linecount >= lastline) && (lastline != 0))
                            writer.Write(line);
                        else
                            writer.WriteLine(line);
                    }
                }
 
            }
 
            File.Delete(filepath);
            File.Move(tempFile, filepath);
        }
 
        static int CountLines(string file)
        {
            int count = 0;
            using (StreamReader r = new StreamReader(file))
            {
                string line;
                while ((line = r.ReadLine()) != null)
                {
                    count++;
                }
            }
            return count;
        }
 
 
    }
}
Print This Post
(8 votes, average: 4.63 out of 5)
Loading ... Loading ...
2,148 views
24
Jul/09
0

Hide GridView column at runtime

To hide a column at runtime you can use to the GridView’s RowDataBound event and set the Visible property to false.

ASP Code (Default.aspx)

1
2
3
4
5
6
<asp:GridView ID="GridView1" runat="server" BorderColor="#666666" 
  BorderStyle="Solid" BorderWidth="1px" OnRowDataBound="GridView1_RowDataBound">
  <HeaderStyle BackColor="#999999" Font-Bold="False" Font-Overline="False" 
   Font-Underline="False" ForeColor="Black" HorizontalAlign="Center" />
  <AlternatingRowStyle BackColor="#E8E8E8" />
</asp:GridView>

C# Code (Default.aspx.cs)

?View Code CSHARP
1
2
3
4
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
e.Row.Cells[0].Visible = false;
}
Print This Post
(5 votes, average: 5.00 out of 5)
Loading ... Loading ...
1,575 views
23
Jul/09
0

Active Directory User Search (C#)

Active Directory Search Class (C#)

?View Code CSHARP
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
        public static DirectoryEntry GetDirectoryEntry()
        {
            DirectoryEntry de = new DirectoryEntry();
            de.Path = "LDAP://DC=" + Environment.UserDomainName + ",DC=net";
            de.AuthenticationType = AuthenticationTypes.Secure;
 
            return de;
        }
 
        public static String FindUser(String userAccount)
        {
            DirectoryEntry entry = GetDirectoryEntry();
 
            try
            {
                DirectorySearcher search = new DirectorySearcher(entry);
                search.Filter = "(&(objectClass=user)" + "(SamAccountName=" + userAccount + "))";
 
                search.PropertiesToLoad.Add("displayName");
                search.PropertiesToLoad.Add("mail");
                search.PropertiesToLoad.Add("mobile");
                search.PropertiesToLoad.Add("canonicalName");
                search.PropertiesToLoad.Add("whenChanged");
                search.PropertiesToLoad.Add("whenCreated");
                search.PropertiesToLoad.Add("lastLogon");
 
                SearchResult result = search.FindOne();
 
                if (result != null)
                {
                    return
                        "\nResults for " + userAccount + "\n" +
                        " Displayname...: " + result.Properties["displayname"][0].ToString() + "\n" +
                        " eMail.........: " + result.Properties["mail"][0].ToString() + "\n" +
                        " Mobile........: " + result.Properties["mobile"][0].ToString() + "\n" +
                        " Path..........: " + result.Properties["canonicalName"][0].ToString() + "\n" +
                        " Changed.......: " + result.Properties["whenChanged"][0].ToString() + "\n" +
                        " Created.......: " + result.Properties["whenCreated"][0].ToString() + "\n" +
                        " Last Logon....: " + DateTime.FromFileTime(Convert.ToInt64(result.Properties["lastLogon"][0]));;
                }
                else
                {
                    return "Object not found";
                }
            }
            catch (Exception ex)
            {
                return ex.Message;
            }
        }
Print This Post
(3 votes, average: 5.00 out of 5)
Loading ... Loading ...
490 views