System.Environment.SpecialFolder does not contain a definition for MyVideos

 

I was trying to set root folder of FolderBrowserDialog to MyVideos folder. I was using .NET Framework 3.5. While compiling I got error - ‘System.Environment.SpecialFolder’ does not contain a definition for ‘MyVideos’.

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace ChromaticBox.MobileHunt.Web.Wireframe
{
    public class Class1
    {
        public void Methof()
        {
            //compilation error
            //this.fldrBrowserDialog.RootFolder = System.Environment.SpecialFolder.MyVideos;

            //workaround
            object fldrBrowserDialog = null;

            if (fldrBrowserDialog != null)
            {
               
Type t = fldrBrowserDialog.GetType();

               
System.Reflection.FieldInfo fi = t.GetField("rootFolder", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);

               
fi.SetValue(fldrBrowserDialog, 0x000e); // 0x000e - represents My Videos folder
            }

           
            var showDialog = fldrBrowserDialog.ShowDialog();
        }
    }
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace ChromaticBox.MobileHunt.Web.Wireframe
{
    public class Class1
    {
        public void Methof()
        {
            //compilation error

            //this.fldrBrowserDialog.RootFolder = System.Environment.SpecialFolder.MyVideos;


            //workaround

            Type t = fldrBrowserDialog.GetType();

            System.Reflection.FieldInfo fi = t.GetField("rootFolder", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);

            fi.SetValue(fldrBrowserDialog, 0x000e); // 0x000e - represents My Videos folder


            fldrBrowserDialog.ShowDialog();
        }
    }
}

 

   1: using System;

   2: using System.Collections.Generic;

   3: using System.Linq;

   4: using System.Web;

   5:  

   6: namespace ChromaticBox.MobileHunt.Web.Wireframe

   7: {

   8:     public class Class1

   9:     {

  10:         public void Methof()

  11:         {

  12:             //compilation error

  13:  

  14:             //this.fldrBrowserDialog.RootFolder = System.Environment.SpecialFolder.MyVideos;

  15:  

  16:  

  17:             //workaround

  18:  

  19:             Type t = fldrBrowserDialog.GetType();

  20:  

  21:             System.Reflection.FieldInfo fi = t.GetField("rootFolder", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);

  22:  

  23:             fi.SetValue(fldrBrowserDialog, 0x000e); // 0x000e - represents My Videos folder

  24:  

  25:  

  26:             fldrBrowserDialog.ShowDialog();

  27:         }

  28:     }

  29: }

   1: using System;

   2: using System.Collections.Generic;

   3: using System.Linq;

   4: using System.Web;

   5:  

   6: namespace ChromaticBox.MobileHunt.Web.Wireframe

   7: {

   8:     public class Class1

   9:     {

  10:         public void Methof()

  11:         {

  12:             //compilation error

  13:  

  14:             //this.fldrBrowserDialog.RootFolder = System.Environment.SpecialFolder.MyVideos;

  15:  

  16:  

  17:             //workaround

  18:  

  19:             Type t = fldrBrowserDialog.GetType();

  20:  

  21:             System.Reflection.FieldInfo fi = t.GetField("rootFolder", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);

  22:  

  23:             fi.SetValue(fldrBrowserDialog, 0x000e); // 0x000e - represents My Videos folder

  24:  

  25:  

  26:             fldrBrowserDialog.ShowDialog();

  27:         }

  28:     }

  29: }

Following is the workaround to above problem -

 

Untitled

   1: using System;

   2: using System.Collections.Generic;

   3: using System.Linq;

   4: using System.Web;

   5:  

   6: namespace ChromaticBox.MobileHunt.Web.Wireframe

   7: {

   8:     public class Class1

   9:     {

  10:         public void Methof()

  11:         {

  12:             //compilation error

  13:  

  14:             //this.fldrBrowserDialog.RootFolder = System.Environment.SpecialFolder.MyVideos;

  15:  

  16:  

  17:             //workaround

  18:  

  19:             Type t = fldrBrowserDialog.GetType();

  20:  

  21:             System.Reflection.FieldInfo fi = t.GetField("rootFolder", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);

  22:  

  23:             fi.SetValue(fldrBrowserDialog, 0x000e); // 0x000e - represents My Videos folder

  24:  

  25:  

  26:             fldrBrowserDialog.ShowDialog();

  27:         }

  28:     }

29: }

 

 

 

 

   1: using System;

   2: using System.Collections.Generic;

   3: using System.Linq;

   4: using System.Web;

   5:  

   6: namespace ChromaticBox.MobileHunt.Web.Wireframe

   7: {

   8:     public class Class1

   9:     {

  10:         public void Methof()

  11:         {

  12:             //compilation error

  13:  

  14:             //this.fldrBrowserDialog.RootFolder = System.Environment.SpecialFolder.MyVideos;

  15:  

  16:  

  17:             //workaround

  18:  

  19:             Type t = fldrBrowserDialog.GetType();

  20:  

  21:             System.Reflection.FieldInfo fi = t.GetField("rootFolder", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);

  22:  

  23:             fi.SetValue(fldrBrowserDialog, 0x000e); // 0x000e - represents My Videos folder

  24:  

  25:  

  26:             fldrBrowserDialog.ShowDialog();

  27:         }

  28:     }

  29: }

1 Comments

  1. I have read so many articles or reviews on the topic of the blogger lovers but this piece of writing is really a pleasant piece of writing, keep it up.|

    Reply

Leave a Comment.