Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

C# 

Why is this giving URI formats are not supported?

PHP Code

<?php 
private const string FILENAME = @"settings.set";
       public 
string settingName { get; set; }
       public 
object setting { get; set; }
       public static List<
Setting> settingList = new List<Setting>();
       static 
string  path = System.Reflection.Assembly.GetExecutingAssembly().CodeBase;
       
//once you have the path you get the directory with:
       
string  directory = System.IO.Path.GetDirectoryName(path);
       private List<
byte> settingsFile = new List<byte>();
       public 
Setting()
        {
            if(
System.IO.File.Exists(directory + FILENAME))
            {
                var 
data = System.Text.Encoding.UTF8.GetString(System.IO.File.ReadAllBytes(directory + FILENAME));
                var 
row = data.Split(';');
                foreach (var 
d in row)
                {
                    var 
r = d.Split('|');
                }
            }
        }
        ~
Setting()
        {
            
saveSettingsFile();
        }
       public static 
void Save(Setting s)
        {
            
settingList.Add(s);
        }
        public static 
void Remove(Setting s)
        {
            
settingList.Remove(s);
        }

        private 
void saveSettingsFile()
        {
            var 
settingsArray = settingList.ToArray();
            foreach (
Setting s in settingsArray)
            {
                foreach(
byte b in System.Text.Encoding.UTF8.GetBytes(s.settingName + "|" + s.setting.ToString() + ";"))
                {
                    
settingsFile.Add(b);
                }
            }
            
System.IO.File.WriteAllBytes(directory + FILENAME, settingsFile.ToArray()); // this is the line throwing the error
        
} 
the error im reciving on closing
Code
An unhandled exception of type 'System.ArgumentException' occurred in mscorlib.dll

Additional information: URI formats are not supported.

it points to

PHP Code

<?php 
System
.IO.File.WriteAllBytes(directory + FILENAME, settingsFile.ToArray()); // this is the line throwing the error 
MAKE REP GREAT AGAIN 2027
What's the value of the variable "directory?"
Based on the value of https://msdn.microsoft.com/en-us/library....110).aspx I think you need to add a backslash
Code
directory + '\\' + FILENAME
I hope this explains everything:
Spoiler (Click to View)

Use
Code
Assembly.GetExecutingAssembly().Location

Also, use
Code
Path.Combine
When joining directories/files instead of +.
Lotta blood to let, peace to make, give a fuk about a check


Possibly Related Threads...
Thread / Author Replies Views Last Post
by greekdevSep 9, 2026 10:36 AM 2 126 Sep 9, 2026 10:36 AM
Last Post: greekdev
[.NET] by aGFjaw--Oct 31, 2017 09:50 AM 18 484 Oct 31, 2017 09:50 AM
Last Post: Dofeus
[Python] by GrunclePug69Dec 20, 2016 02:52 PM 3 363 Dec 20, 2016 02:52 PM
Last Post: Goodies