@@ -206,7 +206,26 @@ private void BrowseFolderButton_Click(object sender, EventArgs e)
206
206
207
207
private void WriteToConfigFile ( string text )
208
208
{
209
- string filePath = Path . Combine ( AppDomain . CurrentDomain . BaseDirectory , "config.txt" ) ;
209
+ string local = Environment . GetFolderPath ( Environment . SpecialFolder . LocalApplicationData ) ;
210
+ string folderName = "HunterModloader" ;
211
+ string configName = "config.txt" ;
212
+ string folderPath = Path . Combine ( local , folderName ) ;
213
+ string filePath = Path . Combine ( local , folderName , configName ) ;
214
+ MessageBox . Show ( filePath ) ;
215
+
216
+ if ( ! System . IO . File . Exists ( folderPath ) )
217
+ {
218
+ try
219
+ {
220
+ Directory . CreateDirectory ( folderPath ) ;
221
+ }
222
+ catch
223
+ {
224
+ MessageBox . Show ( "An error occurred while creating appdata folder" ) ;
225
+ return ;
226
+ }
227
+ }
228
+
210
229
211
230
if ( ! File . Exists ( filePath ) )
212
231
{
@@ -231,12 +250,19 @@ private void WriteToConfigFile(string text)
231
250
catch ( IOException )
232
251
{
233
252
MessageBox . Show ( "An error occurred while writing to config.txt." ) ;
253
+ return ;
234
254
}
235
255
}
236
256
237
257
private string ReadFromConfigFile ( )
238
258
{
239
- string filePath = Path . Combine ( AppDomain . CurrentDomain . BaseDirectory , "config.txt" ) ;
259
+
260
+ string local = Environment . GetFolderPath ( Environment . SpecialFolder . LocalApplicationData ) ;
261
+ string folderName = "HunterModloader" ;
262
+ string configName = "config.txt" ;
263
+ string filePath = Path . Combine ( local , folderName , configName ) ;
264
+ MessageBox . Show ( filePath ) ;
265
+
240
266
string fileContents = "" ;
241
267
242
268
if ( File . Exists ( filePath ) )
@@ -485,12 +511,12 @@ private void InstallZLM()
485
511
486
512
//Now Create all of the directories
487
513
foreach ( string dirPath in Directory . GetDirectories ( ZLMZipExtractionPath , "*" , SearchOption . AllDirectories ) )
488
- Directory . CreateDirectory ( dirPath . Replace ( ZLMZipExtractionPath , $ "{ ValheimGameFolder } \\ BepInEx ") ) ;
514
+ Directory . CreateDirectory ( dirPath . Replace ( ZLMZipExtractionPath , $ "{ ValheimGameFolder } ") ) ;
489
515
490
516
//Copy all the files & Replaces any files with the same name
491
517
foreach ( string newPath in Directory . GetFiles ( ZLMZipExtractionPath , "*.*" ,
492
518
SearchOption . AllDirectories ) )
493
- File . Copy ( newPath , newPath . Replace ( ZLMZipExtractionPath , $ "{ ValheimGameFolder } \\ BepInEx ") , true ) ;
519
+ File . Copy ( newPath , newPath . Replace ( ZLMZipExtractionPath , $ "{ ValheimGameFolder } ") , true ) ;
494
520
495
521
}
496
522
catch
0 commit comments