4

Closed

Use filename as Title if there is no Title

description

If a picture has no title associated with it, most uploader programs use the filename. By adding the following code to the bottom of your PictureItem ctor this will happen:
 
        /// If there is no title, use the filename stub
        if (_title == null || _title == "")
        {
            _title = _fileInfo.Name;
            if (_title.Contains("."))
            {
                _title = _title.Substring(0, _title.IndexOf("."));
            }
        }
Closed May 17, 2007 at 2:32 PM by m2xdam

comments

snaayk wrote Apr 25, 2007 at 9:25 PM

A little more efficient to use

if (string.IsNullorEmpty(_title)){ _title = fileInfo.Name; if (_title.IndexOf(_title, 0)) _title = _title.Substring(0, _title.IndexOf("."));}

snaayk wrote Apr 25, 2007 at 9:25 PM

*Correction

if (string.IsNullorEmpty(_title)){_title = fileInfo.Name;if (_title.IndexOf(".", 0))_title = _title.Substring(0, _title.IndexOf("."));}

wrote May 6, 2007 at 7:09 PM

wrote May 17, 2007 at 2:21 PM

wrote May 17, 2007 at 2:32 PM

wrote Feb 2, 2013 at 4:35 AM

wrote May 13, 2013 at 6:34 PM