Mike Askew 131 Veteran Poster Featured Poster

Any specific output file name?

Mike Askew 131 Veteran Poster Featured Poster

Have You followed all the steps in my posted links?

Mike Askew 131 Veteran Poster Featured Poster

Sounds like the notorious redirect virus.

See Here

edit: And Here

Mike Askew 131 Veteran Poster Featured Poster
href=".*"

Will match

href="/ccm/do/docket?county=65&data=eedd78d10fd9da341e05b25b48b62013"

Very useful regex builder

Mike Askew 131 Veteran Poster Featured Poster

From what I understood:

  • Text file storing first 3 digits of VideoID
  • Read from text file
  • Match first three digits to VideoID's of files
  • If match then copy to output directory

Where did I go wrong?

Mike Askew 131 Veteran Poster Featured Poster

I would suggest providing a copy of the code with this in.

What your currently doing is correct, and so therefore the surrounding code my shed some light on things.

Mike Askew 131 Veteran Poster Featured Poster

Edit: missed the above post when writing this.

Right so now we get into where my knowledge is hazy, delegates :)

My first step would be to use Console.WriteLine() on nearly every line of your threaded code, because this will allow us to see how far it runs before it hangs. Like the "Hello World" in your example code.

Just write say a description of what line is doing into command prompt and see where it gets stuck :)?

Mike Askew 131 Veteran Poster Featured Poster

Untitled84

Sorry didnt make myself clear, the code runs all the way to the end.

Mike Askew 131 Veteran Poster Featured Poster

The provided code runs fine on my computer, can we see the actual?

Mike Askew 131 Veteran Poster Featured Poster

Updated code taking into account new requirement.

        static void Main(string[] args)
        {
            string sourcePath = @"E:\Source\";
            string targetPath = @"E:\Destination\";

            StreamReader strmReader = new StreamReader(sourcePath + "videoID.txt");

            string videoIDs = strmReader.ReadToEnd();

            videoIDs = Regex.Replace(videoIDs, "\\r\\n", ",");

            string[] individualVidIDs = videoIDs.Split(',');
            string[] tempArray = Directory.GetFiles(sourcePath);
            List<string> filesInFolder = new List<string>();
            foreach (string fileName in tempArray)
            {
                filesInFolder.Add(fileName);
            }
            filesInFolder.Remove(sourcePath + "videoID.txt");

            foreach (string videoID in individualVidIDs)
            {
                Console.WriteLine("VideoID = {0}", videoID);
                Console.WriteLine();

                foreach (string fileName in filesInFolder)
                {
                    if (fileName.Substring(fileName.LastIndexOf('\\') + 1, 3) == videoID)
                    {
                        Console.WriteLine("Video {0} has been found.", fileName.Substring(fileName.LastIndexOf('\\') + 1));

                        string destFile = targetPath + "\\" + (fileName.Substring(fileName.LastIndexOf('\\') + 1));
                        System.IO.File.Copy(fileName, destFile, true);
                        Console.WriteLine();
                    }
                    else
                    {
                        Console.WriteLine("Video {0} does not match VideoID!", fileName.Substring(fileName.LastIndexOf('\\') + 1));
                        Console.WriteLine();
                    }
                }
            }

            Console.ReadLine();
        }
Mike Askew 131 Veteran Poster Featured Poster

I did it using the following:

            string sourcePath = @"E:\Source";
            string targetPath = @"E:\Destination";

            StreamReader strmReader = new StreamReader(@"E:\Source\videoID.txt");

            string videoIDs = strmReader.ReadToEnd();

            videoIDs = Regex.Replace(videoIDs, "\\r\\n", ",");

            string[] individualVidIDs = videoIDs.Split(',');

            foreach (string videoID in individualVidIDs)
            {
                Console.WriteLine("Checking if video {0} exists...", videoID);
                string tempFilePath = sourcePath + "\\" + videoID + ".txt";
                if (File.Exists(tempFilePath))
                {
                    Console.WriteLine("Video {0} has been found...", videoID);

                    string fileName = System.IO.Path.GetFileName(tempFilePath);
                    string destFile = System.IO.Path.Combine(targetPath, fileName);
                    System.IO.File.Copy(tempFilePath, destFile, true);
                    Console.WriteLine();
                }
                else
                {
                    Console.WriteLine("Video {0} has NOT been found!", videoID);
                    Console.WriteLine();
                }
            }

This assumes that the videoID file is literally seperated by new lines and doesnt have like a comma etc.

Else the RegEx wouldnt be needed to remove the newline escape codes.

I used files like this to test: 10001.txt

Mike Askew 131 Veteran Poster Featured Poster

Move your methods for checking files etc to the splashScreen_Shown event.

This is run once the form appears on screen

EDIT:-

The reason all the checks are currently done before the splashscreen appears are because it is in the splashScreen_Load event which will fire before the form is visible as it loads everything required etc. Thought I'd just mention that for clarification purposes

Mike Askew 131 Veteran Poster Featured Poster

No worries, mark thread as solved if nothing else needs fixing :)

Mike Askew 131 Veteran Poster Featured Poster

I have achieved the desired using the following (Apologies for time delay i've never had to do C# to XML before :D, Presuming your using C# ofc forgot to ask that >.<)

static void Main()
        {
            DataTable table = GetTable();

            XmlWriterSettings settings = new XmlWriterSettings();
            settings.Indent = true;

            using (XmlWriter writer = XmlWriter.Create(@"FilePathHere", settings))
            {
                writer.WriteStartDocument();
                writer.WriteStartElement("Data");

                string currentManager = "";
                int currentTotal = 0;

                List<String> lstManagerCounts = new List<String>();
                foreach (DataRow row in table.Rows) //Get unique managerID's and their totals into a list
                {
                    if (currentManager != row.ItemArray[0].ToString())
                    {
                        if (currentManager != "")
                            lstManagerCounts.Add(string.Format("{0},{1}", currentManager, currentTotal));

                        currentManager = row.ItemArray[0].ToString();
                        currentTotal = 0;
                    }
                    currentTotal += (int)row.ItemArray[2];
                }
                lstManagerCounts.Add(string.Format("{0},{1}", currentManager, currentTotal));

                foreach (string entry in lstManagerCounts) //Loop the unique ManagerId's finding related entries and listing them
                {
                    string ManagerID = entry.Substring(0, entry.IndexOf(','));
                    string Total = entry.Substring(entry.IndexOf(',')+1);

                    writer.WriteStartElement(ManagerID);
                    writer.WriteAttributeString("Total", Total);

                    foreach (DataRow dRow in table.Rows)
                    {
                        if (dRow.ItemArray[0].ToString() == ManagerID)
                        {
                            writer.WriteStartElement(dRow.ItemArray[1].ToString());
                            writer.WriteAttributeString("Value", dRow.ItemArray[2].ToString());
                            writer.WriteEndElement();
                        }
                    }
                    writer.WriteEndElement();
                }
                writer.WriteEndDocument();
            }
        }

        static DataTable GetTable() //Setting up the datatable using provided example data
        {
            DataTable table = new DataTable();
            table.Columns.Add("ManagerID", typeof(string));
            table.Columns.Add("VendorID", typeof(string));
            table.Columns.Add("Count", typeof(int));
            table.Rows.Add("M1", "V1", 10);
            table.Rows.Add("M1", "V2", 5);
            table.Rows.Add("M2", "V1", 10);
            table.Rows.Add("M2", "V2", 5);
            table.Rows.Add("M3", "V1", 10);
            table.Rows.Add("M3", "V2", 5);
            return table;
        }

It works by looking through the data in a prelim, identifying all unique manager ID's and getting the totals of their entries (as XMLWriter is forwards only).

I then re-loop through the table matching the ManagerID's and creating nodes if they match, else …

Mike Askew 131 Veteran Poster Featured Poster

You haven't said how you want the XML laid out, nobody can help without that information.

Ie.

<M1 Total='15'>
    <V1 Value='10' />
    <V2 Value='5' />
</M1>

Or.

<M1>
    <Total>15</Total>
    <V1>
        <Value>10</Value>
    </V1>
    <V2>
        <Value>5</Value>
    </V2>
</M1>
Mike Askew 131 Veteran Poster Featured Poster

Well in terms of handling the account number and surname search possibilities, you can use a TryParse to distinguish which you are dealing with, I am assuming an account number is entirely numeric.

string InputFromTextBox = "0011223344";
int OutputAccountNumber;

// if bool = true, its account number, else false, surname
bool IsAccountNumber = int32.TryParse(InputFromTextBox, out OutputAccountNumber);
Mike Askew 131 Veteran Poster Featured Poster

Could try a message box displaying a datetime down to milliseconds to see which executes first? Should be a slightly noticeable difference in the millisecond portion of the time?

Mike Askew 131 Veteran Poster Featured Poster

Could try running it with a sleep of (500), equivalent of half a second.


Thread.Sleep() Is safe as it literally pauses execution of the thread and so therefore just makes the computer wait before running your next line of code, might give it the time to close the connection properly though in personal experience i've never had your issue.

Mike Askew 131 Veteran Poster Featured Poster
Mike Askew 131 Veteran Poster Featured Poster

@Jigz: Capital L; Little l. I do know how to spell the word and am not silly :)

@Momer: whats diff between "xxx" = "xxx" and StrComp('xxx','xxx')? Apart from one would be a bool and one an int?

Mike Askew 131 Veteran Poster Featured Poster
for (int i = 0; i < sample.Count; i++)
            {
                Console.WriteLine(sample[i]);
                sample[i] -= 1; //This line is shorthand for sample[i] = sample[i] - 1
            }

That should do the trick :)

Mike Askew 131 Veteran Poster Featured Poster

It should do, i also tested this in visual studio to check if HeLlO matched Hello and it did not, you may wish to check your login validation code itself and not the mismatch of case sensitivity :)

Mike Askew 131 Veteran Poster Featured Poster
MessageBox.Show("MessageGoesHere");

This, when running a windows forms application, will display a popup message box on screen displaying the information you have passed it within the brackets.

return x;

Return is used to send a variable back from a method to the block of code that called the method. It is a required line of code for methods that are not declared as void (returns nothing)

For example:

int a = 10;
int b = 5;

int d = Addition(a, b);

public int Addition(int Num1, int Num2) //Method returning a parameter of type Integer
{
    int c = Num1 + Num2;
    return c;
}

In the above example we have two integers, a and b, which I am passing to a simple addition method that will add them together and give me back a value to set integer d too.

In this method the return keyword plays the role of passing the value of 'c' back to the original location the method was called from, in this case line 4.

Mike Askew 131 Veteran Poster Featured Poster

Kk lemme know, sorry wasnt of more use

Mike Askew 131 Veteran Poster Featured Poster

It is strange indeed, calling the .Dispose() method is the garbage cleaner for the two variables we call it on so it should work. Stumps me at this point tbh.

Yeah could give it a shot using a .txt though you can also open and edit csv's in notepad :P?

Mike Askew 131 Veteran Poster Featured Poster
private void RowCount()
      {
         DataTable ConfDT = new DataTable();
         string tempPath = @"C:\Download Report Sheets\";
         string strConn = @"Driver={Microsoft Text Driver (*.txt; *.csv)};Dbq=" + tempPath + @"\;Extensions=asc,csv,tab,txt";
         OdbcConnection conn = new OdbcConnection(strConn);
         OdbcDataAdapter da = new OdbcDataAdapter("Select * from Releases.csv", conn);//TestFile
         conn.Open();
         da.Fill(ConfDT);
         ConfigGrid.DataSource = ConfDT;
         ConfigGrid.Columns[0].DefaultCellStyle.Format = "G";
         conn.Close();
         da.Dispose(); //Try that
         conn.Dispose(); //Try that
      }

You may have already done it but try adding in the two lines at the bottom of the code block.

Technically im not sure why those are crashing as the variables would only live for the lifespan of the method anyway as they are local to it.

The error itself points to the file your trying to open already being open by something else or not closing quick enough within your program. How many times is the program executing this per second?

Mike Askew 131 Veteran Poster Featured Poster

What do you mean by set case sensitivity?

If you are comparing within c# the strings that you pull from the password field of the database will be compared case sensitive by default.

Mike Askew 131 Veteran Poster Featured Poster

Again not being written in an IDE but still.

Could you not do something like the following:

Console.Writeline("\t Job Name \t Job Size \t Time")
For (int i = 0; i < container.Count; i++)
{
    String.Format("{0}. \t {1} \t {2} \t {3}", (i+1), jobname[i], job[i], time[i]);
}

This code uses a string formatter to put the values into each line of the string, they are spaced [hopefully] evenly using the [TAB] char "\t" however you may need to fine tune the tabbing.

Hope that helps.

Mike Askew 131 Veteran Poster Featured Poster

As a matter of good practice I would manually dispose of the elements after each use, not relying on a garbage collection then and should hopefully resolve the error.

Mike Askew 131 Veteran Poster Featured Poster

Kind of impossible to tell from the information provided.

Common sense would say either the Baza.Schedule object doesnt contain anything row wise or there is a failing link in your database working somewhere preventing the rows being pulled?

Maybe give us a more extensive code post and an insight into the type of informaation that you should be expecting?

Mike Askew 131 Veteran Poster Featured Poster

Yeah i had a feeling the ! might error as i wrote it on the fly on here not in visual studio :D would of just had to add an extra set of brackets around the whole expression to apply the ! too :)

Any other issues?

Mike Askew 131 Veteran Poster Featured Poster

Forgive me if im wrong for arguing though, if you made your label span from one side of the form to the other, and did text align center, the text (regardless of length) will always sit within the center or the form.

From what your saying thats the simplest way to gain your outcome. Unless your wanting something else and im misunderstanding in which case clarify further.

Mike Askew 131 Veteran Poster Featured Poster

Could try something like:

while (totality <= 50000)
            {
                if (!(totality + job[i]) >= 50000)
                    totality = totality + job[i];
                i++;
            }
Mike Askew 131 Veteran Poster Featured Poster

So what exactly are you trying to do? Move the label around so that the text always appears in the middle?

Could you not just make the label the maximum size it could be and set the text align to middle?

Mike Askew 131 Veteran Poster Featured Poster

Surely there is just a lack of rows in whatever you are pulling as you are looking for the row (2) so the third row in. Run a debug and use a break point to see what is contained within the schedule and see if that helps to solve the issue?

Im making assumptions but the error as Thines01 said could either be that it is null or that the schedule actually contains no rows.

Mike Askew 131 Veteran Poster Featured Poster

Have a look at this.

Mike Askew 131 Veteran Poster Featured Poster

You could simply use the array that I used to switch the image back from the placeholder value and compare if they hold the same value there so:

if (Images[1,1] == Images[3,1])
{
    bool MatchFound = true;
}

Again just using a for loop or something to search for the name of the sender to allow the array match to happen?

Mike Askew 131 Veteran Poster Featured Poster

Apologies for double post can't edit last. The following code may do what you require, obviously you will need to adapt it for your images and resources folder etc.

public partial class Form1 : Form
    {
        Image[] Pictures = new Image[] { Properties.Resources.RandomImage1, Properties.Resources.RandomImage2, Properties.Resources.RandomImage3, Properties.Resources.RandomImage4, Properties.Resources.PlaceHolder };
        string[,] Images = new string[4,2];


        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            //Can make this setting happen randomly as you do
            img1.Image = Pictures[0];
            img2.Image = Pictures[1];
            img3.Image = Pictures[2];
            img4.Image= Pictures[3];
            //When you randomly set, set the second part of the array to the number in the Pictures array that holds that images position.
            Images[0, 0] = "img1";
            Images[0, 1] = "0";
            Images[1, 0] = "img2";
            Images[1, 1] = "1";
            Images[2, 0] = "img3";
            Images[2, 1] = "2";
            Images[3, 0] = "img4";
            Images[3, 1] = "3";
        }

        private void ImageClick(object sender, EventArgs e)
        {
            //If picture is not using the placeholder image
            if (((PictureBox)sender).Image != Pictures[4])
            {
                ((PictureBox)sender).Image = Pictures[4];
            }
            else
            {
                //Set back to the previous image using the stored location in the array
                for (int i = 0; i < Images.Length / 2; i++)
                {
                    if (((PictureBox)sender).Name == Images[i, 0])
                    {
                        ((PictureBox)sender).Image = Pictures[Convert.ToInt32(Images[i, 1])];
                    }
                }
            }
        }
    }
Mike Askew 131 Veteran Poster Featured Poster

So the issue is that when you click on a non-visible picture box it doesnt become visible?

I would assume you cant click on a picture box you cannot see therefore may have to consider setting the picture to a placeholder picture and store the assigned images in an array so that when the picture is clicked it flicks between the placeholder 'hidden' image and the actual array stored one.

Mike Askew 131 Veteran Poster Featured Poster

Do you mean generate a random number between those boundaries?

Mike Askew 131 Veteran Poster Featured Poster

Try this:

If password.text <> confirmpassword.text Then
    Msgbox("Password not the same")
End If
Mike Askew 131 Veteran Poster Featured Poster

Have a look at THIS webpage.

Can apply the same technique of date/time measurement possibly? Not entirely sure though.

Mike Askew 131 Veteran Poster Featured Poster

"Data type mismatch in criteria expression." is an error relating to your SQL.

In this case you are putting '11' around the number 11. When using numbers in the SQL you should leave out the ' ' :)