Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions WindowsFormsApp1/Form2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using System.Windows.Forms;
using System;
using System.IO;

namespace WindowsFormsApp1
{
public partial class Form2 : Form
Expand All @@ -31,10 +32,22 @@ private void button3_Click(object sender, EventArgs e)

private void button1_Click(object sender, EventArgs e)
{
string appDataLocalPath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);

// Construct the full path to your directory
string yourDirectoryPath = Path.Combine(appDataLocalPath, "FiveM", "FiveM.app", "data");
string fivemPath = Utils.GetFiveMPath();

if (string.IsNullOrEmpty(fivemPath))
{
MessageBox.Show("Could not find FiveM installation. Cancelling auto clean up.");
return;
}

if (!Directory.Exists(fivemPath))
{
MessageBox.Show("FiveM directory does not exist. Cancelling auto clean up.");
return;
}

string yourDirectoryPath = Path.Combine(fivemPath, "FiveM.app", "data");

// Check if the main directory exists
if (Directory.Exists(yourDirectoryPath))
Expand Down
31 changes: 31 additions & 0 deletions WindowsFormsApp1/Utils.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WindowsFormsApp1
{
internal class Utils
{
public static string GetFiveMPath()
{
string startMenuPath = Environment.GetFolderPath(Environment.SpecialFolder.StartMenu);
string shortcutPath = Path.Combine(startMenuPath, "Programs", "FiveM.lnk");

if (!File.Exists(shortcutPath))
{
return null;
}

// COM access is a bit gross, but meh
dynamic shell = Activator.CreateInstance(Type.GetTypeFromProgID("WScript.Shell"));
dynamic shortcut = shell.CreateShortcut(shortcutPath);

string directoryPath = Path.GetDirectoryName(shortcut.TargetPath);

return directoryPath;
}
}
}
1 change: 1 addition & 0 deletions WindowsFormsApp1/WindowsFormsApp1.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
<Compile Include="RJButton.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Utils.cs" />
<EmbeddedResource Include="Form1.resx">
<DependentUpon>Form1.cs</DependentUpon>
</EmbeddedResource>
Expand Down