Jump to content
  • Revista PROGRAMAR: Já está disponível a edição #60 da revista programar. Faz já o download aqui!

Thebas

Ajuda num erro/resultado inesplicavel?!?

Recommended Posts

Thebas

É o seguinte... Estou a fazer um visualizador de imagens... e tenho o seguinte codigo:

           

            bool verify = true;

            string supportedtypes = "jpg;gif;bmp;jpeg;png;ico;wmf;BMP;GIF;JPG;PNG;ICO;JPEG;WMF";

            string[] extencionssupported = supportedtypes.Split(';');

            filevec = extencionssupported;

            foreach (string type in extencionssupported)

            {

                if (verify)

                {

                    filevec = Directory.GetFiles(Directory.GetCurrentDirectory(), string.Format("*.{0}", type), (cbsub.Checked) ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly);

                    verify = false;

                }

                else

                {

                    string[] tempvec=Directory.GetFiles(Directory.GetCurrentDirectory(), string.Format("*.{0}", type), (cbsub.Checked) ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly);

                    filevec.Concat(tempvec);

                }

            }

no vector de strings de nome filevec apenas me aparece as imagens terminadas em *.jpg.... os outros formatos nao aparecem no vector alguem me ajuda pls? desde já obrigado :cheesygrin: Abraço

Share this post


Link to post
Share on other sites
Betovsky

O Concat não te altera o filevec. Esse método devolve como resultado a concatenação, por isso tens que guardar isso. Presumo que estejas a usar LINQ,

            bool verify = true;
            string supportedtypes = "jpg;gif;bmp;jpeg;png;ico;wmf;BMP;GIF;JPG;PNG;ICO;JPEG;WMF";
            string[] extencionssupported = supportedtypes.Split(';');
            filevec = extencionssupported;
            foreach (string type in extencionssupported)
            {
                if (verify)
                {
                    filevec = Directory.GetFiles(Directory.GetCurrentDirectory(), string.Format("*.{0}", type), (cbsub.Checked) ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly);
                    verify = false;
                }
                else
                {
                    string[] tempvec=Directory.GetFiles(Directory.GetCurrentDirectory(), string.Format("*.{0}", type), (cbsub.Checked) ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly);
                    filevec = filevec.Concat(tempvec).ToArray();
                }
            }


"Give a man a fish and he will eat for a day; Teach a man to fish and he will eat for a lifetime. The moral? READ THE MANUAL !"

Sign on a computer system consultant's desk

Share this post


Link to post
Share on other sites
Thebas

O Concat não te altera o filevec. Esse método devolve como resultado a concatenação, por isso tens que guardar isso. Presumo que estejas a usar LINQ,

            bool verify = true;
            string supportedtypes = "jpg;gif;bmp;jpeg;png;ico;wmf;BMP;GIF;JPG;PNG;ICO;JPEG;WMF";
            string[] extencionssupported = supportedtypes.Split(';');
            filevec = extencionssupported;
            foreach (string type in extencionssupported)
            {
                if (verify)
                {
                    filevec = Directory.GetFiles(Directory.GetCurrentDirectory(), string.Format("*.{0}", type), (cbsub.Checked) ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly);
                    verify = false;
                }
                else
                {
                    string[] tempvec=Directory.GetFiles(Directory.GetCurrentDirectory(), string.Format("*.{0}", type), (cbsub.Checked) ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly);
                    filevec = filevec.Concat(tempvec).ToArray();
                }
            }

é isso msm obrigadao! ... são cenas que nos escapam soke ao fim lixam tudo... xD abraço

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.