Jarski
Jarski
CC#
Created by Jarski on 11/3/2023 in #help
❔ "string was not recognised as valid DateTime"
Task scheduler on startup. Gotcha. Will look into this later. Appreciate the help.
38 replies
CC#
Created by Jarski on 11/3/2023 in #help
❔ "string was not recognised as valid DateTime"
Or should I need to add something to the code?
38 replies
CC#
Created by Jarski on 11/3/2023 in #help
❔ "string was not recognised as valid DateTime"
If I have the program in the startup folder, will it autolaunch with admin privileges?
38 replies
CC#
Created by Jarski on 11/3/2023 in #help
❔ "string was not recognised as valid DateTime"
That part looks to be working now.
38 replies
CC#
Created by Jarski on 11/3/2023 in #help
❔ "string was not recognised as valid DateTime"
I just manually set it properly to a random date and time. Turns out I needed the time too. Eg: "00:00:00 00:00:00"
38 replies
CC#
Created by Jarski on 11/3/2023 in #help
❔ "string was not recognised as valid DateTime"
Changing it to 00:00:00 like the other one isn't the solution apparently. What format should I need to give this thing
38 replies
CC#
Created by Jarski on 11/3/2023 in #help
❔ "string was not recognised as valid DateTime"
No description
38 replies
CC#
Created by Jarski on 11/3/2023 in #help
❔ "string was not recognised as valid DateTime"
Yeah. Looks to be the issue. I'll give it a go now and check.
38 replies
CC#
Created by Jarski on 11/3/2023 in #help
❔ "string was not recognised as valid DateTime"
That looks like my error.
38 replies
CC#
Created by Jarski on 11/3/2023 in #help
❔ "string was not recognised as valid DateTime"
It works just fine running as a build from vs
38 replies
CC#
Created by Jarski on 11/3/2023 in #help
❔ "string was not recognised as valid DateTime"
It's not throwing the error on visual studio.
38 replies
CC#
Created by Jarski on 11/3/2023 in #help
❔ "string was not recognised as valid DateTime"
apologies, using wrong key
38 replies
CC#
Created by Jarski on 11/3/2023 in #help
❔ "string was not recognised as valid DateTime"
heres the properties:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="FileBackupApp.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
<userSettings>
<FileBackupApp.Properties.Settings>
<setting name="SourceDirectory" serializeAs="String">
<value />
</setting>
<setting name="DestinationDirectory" serializeAs="String">
<value />
</setting>
<setting name="LastBackupTime" serializeAs="String">
<value />
</setting>
<setting name="UserDefinedBackupTime" serializeAs="String">
<value>00:00:00</value>
</setting>
</FileBackupApp.Properties.Settings>
</userSettings>
</configuration>
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="FileBackupApp.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
<userSettings>
<FileBackupApp.Properties.Settings>
<setting name="SourceDirectory" serializeAs="String">
<value />
</setting>
<setting name="DestinationDirectory" serializeAs="String">
<value />
</setting>
<setting name="LastBackupTime" serializeAs="String">
<value />
</setting>
<setting name="UserDefinedBackupTime" serializeAs="String">
<value>00:00:00</value>
</setting>
</FileBackupApp.Properties.Settings>
</userSettings>
</configuration>
38 replies
CC#
Created by Jarski on 11/3/2023 in #help
❔ "string was not recognised as valid DateTime"
trying to find where it actually saves the properties.
38 replies
CC#
Created by Jarski on 11/3/2023 in #help
❔ "string was not recognised as valid DateTime"
no idea, i reference datetime strings a couple times.
38 replies
CC#
Created by Jarski on 8/20/2023 in #help
❔ port scanner for game servers?
Will take a look
6 replies
CC#
Created by Jarski on 8/20/2023 in #help
❔ port scanner for game servers?
Ah. I need udp. Not tcp.
6 replies
CC#
Created by Jarski on 8/20/2023 in #help
❔ port scanner for game servers?
private async Task PerformNetworkScanAsync()
{
await Task.Run(() =>
{
string localIpAddress = GetLocalIpAddress();
if (!string.IsNullOrEmpty(localIpAddress))
{
ScanNetworkForRustServers(localIpAddress);
}
});
}

private string GetLocalIpAddress()
{
string hostName = Dns.GetHostName();
IPHostEntry hostEntry = Dns.GetHostEntry(hostName);
foreach (IPAddress ipAddress in hostEntry.AddressList)
{
if (ipAddress.AddressFamily == AddressFamily.InterNetwork)
{
return ipAddress.ToString();
}
}
return null;
}

private void ScanNetworkForRustServers(string localIpAddress)
{
string[] ipSegments = localIpAddress.Split('.');
if (ipSegments.Length != 4)
{
resultsListBox.Items.Add("Invalid local IP format.");
return;
}

string baseIpAddress = $"{ipSegments[0]}.{ipSegments[1]}.{ipSegments[2]}";

for (int i = 1; i <= 255; i++)
{
string ipAddress = $"{baseIpAddress}.{i}";
if (CheckPort(ipAddress, 28015))
{
resultsListBox.Items.Add($"Server found: {ipAddress}:28015");
}
}
}

private bool CheckPort(string ipAddress, int port)
{
using (TcpClient tcpClient = new TcpClient())
{
try
{
tcpClient.Connect(ipAddress, port);
return true; // Port is open
}
catch (SocketException)
{
return false; // Port is closed
}
}
}
private async Task PerformNetworkScanAsync()
{
await Task.Run(() =>
{
string localIpAddress = GetLocalIpAddress();
if (!string.IsNullOrEmpty(localIpAddress))
{
ScanNetworkForRustServers(localIpAddress);
}
});
}

private string GetLocalIpAddress()
{
string hostName = Dns.GetHostName();
IPHostEntry hostEntry = Dns.GetHostEntry(hostName);
foreach (IPAddress ipAddress in hostEntry.AddressList)
{
if (ipAddress.AddressFamily == AddressFamily.InterNetwork)
{
return ipAddress.ToString();
}
}
return null;
}

private void ScanNetworkForRustServers(string localIpAddress)
{
string[] ipSegments = localIpAddress.Split('.');
if (ipSegments.Length != 4)
{
resultsListBox.Items.Add("Invalid local IP format.");
return;
}

string baseIpAddress = $"{ipSegments[0]}.{ipSegments[1]}.{ipSegments[2]}";

for (int i = 1; i <= 255; i++)
{
string ipAddress = $"{baseIpAddress}.{i}";
if (CheckPort(ipAddress, 28015))
{
resultsListBox.Items.Add($"Server found: {ipAddress}:28015");
}
}
}

private bool CheckPort(string ipAddress, int port)
{
using (TcpClient tcpClient = new TcpClient())
{
try
{
tcpClient.Connect(ipAddress, port);
return true; // Port is open
}
catch (SocketException)
{
return false; // Port is closed
}
}
}
6 replies